Cloudera
DS-200 · Question #15
You have a directory containing a number of comma-separated files. Each file has three columns and each filename has a .csv extension. You want to have a single tab-separated file (all .tsv) that…
The correct answer is B. Find . -name `name * .CSV' | cat | awk `BEGIN {FS = "," OFS = "\t"} {print $1, $2, $3}' > all.tsv. See the full explanation below for the reasoning.
Question
You have a directory containing a number of comma-separated files. Each file has three columns and each filename has a .csv extension. You want to have a single tab-separated file (all .tsv) that contains all the rows from all the files. Which command is guaranteed to produce the desired output if you have more than 20,000 files to process?
Options
- AFind . -name
*, CSV' ?print0 | sargs -0 cat | tr,' `\t>t; all.tsv - BFind . -name
name * .CSV' | cat | awkBEGIN {FS = "," OFS = "\t"} {print $1, $2, $3}' > all.tsv - CFind . -name
*.CSV' | tr,' `\t' | cat>; all.tsv - DFind . -name `*.CSV' | cat > all.tsv
- ECat *.CSV > all.tsv
How the community answered
(63 responses)- A8% (5)
- B73% (46)
- C14% (9)
- D2% (1)
- E3% (2)
Community Discussion
No community discussion yet for this question.