Create a Csv file
How do i create a Csv file from the list of file in the folder.
Particular folder has lot of pdf files 78945.pdf 12305.pdf Csv file should look something like this Column1,Column2 78945.pdf,78945 12305.pdf,12305 Can someone point me in the right direction. I know in Shell i have to use ls command and export it to csv but not sure how to get the second column. Thanks |
You could do something like this:
Code:
for i in `ls *.pdf`; do echo $i,${i%.pdf}; done > list.csv |
Thank you. how do i add the First Line with Column Names ?
|
Quote:
http://www.linuxquestions.org/questi...v-file-663835/ http://www.linuxquestions.org/questi...to-tab-683201/ http://www.linuxquestions.org/questi...t-file-699125/ http://www.linuxquestions.org/questi...v-file-898955/ |
sed -i '1icolumn1,column2' list.csv found this on web.
|
Assuming a script, just echo those lines in first. Also, I would not use ls in case of word splitting and use a simple glob (ie. for f in *)
|
Quote:
Code:
{ echo 'Column1,Column2'; for i in *.pdf; do echo "$i,${i%.pdf}"; done; } > list.csv |
All times are GMT -5. The time now is 04:18 PM. |