Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: converting txt to csv and formattingby gurpreetsingh13 (Scribe) |
on Jul 07, 2014 at 06:03 UTC ( [id://1092520]=note: print w/replies, xml ) | Need Help?? |
Something out of the way though, but I would say you can try this if you have Vim. 1.Simply make a copy of the file and open it in Vim 2.Use this search-and-replace to surround all names with quotes. 3. Again a search and replace to put comma at the end of each line. 4.Then record a simple Macro or make it manually as: 5. Replay the macro N number of times where N >= records or you can say N = (No. of lines/3) 6. Finally remove the commas at the end of each line with the command: Save the file and you are done. Just rename it to <Filename>.csv and the file is ready. You can probably emit some steps above if you are good at regex by putting comma in first search-and-replace only at the end of names and phone numbers. Or making a comma in macro itself. But better forget all that and this simple one would work I believe. Hope that solves the problem.
In Section
Seekers of Perl Wisdom
|
|