Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert a vertical line text file to a csv file with parameters

I tried several ways to transform the text with a column into a summarized csv file based on the contents of the file but I couldn’t.

record does not start with comma = first column
record that has a comma at the beginning = concatenates with the first

When you find the next record that doesn’t have a comma at the beginning, start on another line

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel


Text file to process:

08-ipa_group
,evouth.zip
,zipe.zip
,auth-service.zip
18-ws-api_group
,mocks.zip
,auth-service.zip
,a-service.zip

Output

08-ipa_group,evouth.zip,zipe.zip,auth-service.zip
18-ws-api_group,mocks.zip,auth-service.zip,a-service.zip

>Solution :

Using awk:

awk -v ORS= '
/^[^,]/ {
  eol()
}
END {
  eol()
}
function eol() {
  if (NR > 1)
    print "\n"
}
1' file
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading