Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 3
    edit your post to include a sample of the input data and how you want it to look. Just a couple of lines is enough, as long as they're representative of the data. Commented Aug 29, 2024 at 19:57
  • 1
    also update the question to show the (wrong) output generated by your code Commented Aug 29, 2024 at 20:18
  • using this dummy record - SW12_1AB long1 lat1 (tabs between columns) - your script generates - long1,lat1,SW12_1AB - when the file has unix line endings (\n); when the file has windows line endings (\r\n) your script generates - SW12_1AB1; I'm guessing your file may have windows line endings in which case you'll either want to remove them (eg, dos2unix pc0.csv) or modify the awk script to factor in the trailing \r character; providing us with sample inputs and (expected, wrong) outputs will help us to determine the issue(s) and how to proceed Commented Aug 29, 2024 at 20:25
  • 1
    Several solutions suggest themselves, using perl, awk, or even bash, but without a fuller description of your system, and a short example of your input (are there TABs?) and the desired output, I can't pick a silution. Commented Aug 29, 2024 at 20:42
  • 1
    Please add to you post some columns of the input file. In you first awk command you write {FS="\t"; OFS=","} , then the input file is not a CSV, it's a tsv. Am I right? Commented Aug 30, 2024 at 13:53