Spread a File into Multiple. Csv Files per Each Line of Inputfile Read

I have .csv file with over 1000 rows that contains on each row a number ie, "2224441214" that is the only value on the row. I need to break that file up into a .csv file named "2224441214.csv" for each row.

ie, "2224441214.csv" "22655443.csv" "2222211564.csv"

2

1 Answer

It can be done with below awk command,

awk '{print > $0".csv"}' infile.csv

This will create multi .csv files named with numbers read from infile.csv

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest