anandknr
Member
I am trying to read a csv file which can be of 'n' number of columns. My requirement to read first column and then based on its value I need to consider/ignore that row. At the end, I will create a new csv file which have same columns as first one, but only with selected rows.
Issue I am Facing - There is no fixed column numbers in csv I am uploading so I can’t use a temp-table. I have to read the entire line and then parse the first column from it. The CSV created from windows will have carriage return (^M) and because of this it won’t read the last line. See this url. Please note if we import to a temp-table this is not an issue.
Example - I am attaching a sample csv (input.txt) and program (filterRecords.p) to read it. It will then create output csv. Since this site wont allow .csv attachment, I renamed it with .txt extension. Also I am not sure if this site will change the ^M characters from input.txt, so added a screenshot how my input.txt looks like in my vim editor.
Testing this in unix.
Issue I am Facing - There is no fixed column numbers in csv I am uploading so I can’t use a temp-table. I have to read the entire line and then parse the first column from it. The CSV created from windows will have carriage return (^M) and because of this it won’t read the last line. See this url. Please note if we import to a temp-table this is not an issue.
Example - I am attaching a sample csv (input.txt) and program (filterRecords.p) to read it. It will then create output csv. Since this site wont allow .csv attachment, I renamed it with .txt extension. Also I am not sure if this site will change the ^M characters from input.txt, so added a screenshot how my input.txt looks like in my vim editor.
Testing this in unix.