How can I write a data table to a CSV file without including the column headers? If I am unable to save a CSV without the headers, then how can I delete the first line of the CSV file without opening Notepad and using keystrokes?
Hi @Jack Dawson ,
After the. CSV file is created, please use CSV/TXT Package to read the existing. CSV file and write a new file without headers at a new location.
Hi Tamil,
Thank you for your reply. I am trying to figure out HOW to write to a new CSV file without the headers. What action or package is needed to do that? I know how to use the Write to file action in the Data Table package, but it doesn't give you the option to exclude writing the column headers. What action is needed for me to write the data in a data table out to a CSV file without including the column headers?
Hi @Jack Dawson,
Please follow the below steps,
You have to create the CSV file with a header using the Write to File "Data Table Package". Once the file is created, please use CSV/TXT Package to read the existing file and write a new file "Log into File Action" without headers at a new location
Hi @Tamil Arasu ,
I appreciate your help but I am still not seeing how I would write the contents of a data table out to a CSV file without the column header. When I open and read the CSV file, it loads into a data table. When I try to use the Log to File action, I can select the data table but I can only output a single column and row. I guess I could loop every column and row to with the Log to File action, but then I lose the comma delimiters in the file that is created - which will not work for me. I need a CSV file created as my output, just without the column header. If I am missing something, I would appreciate you letting me know what that is.
Would you be able to share the sample file of CSV and the example file without headers? I will try to create scripts and share them with you.
I was able to get this working by using a Python script, but I would love it if there was an easier way to remove the column headers from a CSV file. Seems unnecessarily difficult since the previous automation software the I used had a checkbox for including column headers when writing a data table to a CSV.
Please find two CSV files attached to this post. One includes the column headers in row 1 and the other does not include the column headers. I would appreciate any help you can provide.
Hi @Jack Dawson ,
Thanks for sharing the files
I saw the 2 files, 1st with headers, 2nd without headers.
Please use the below action to read the data.csv file which contains the header, In the action, Please uncheck the Contains Header
Loop the data row by row and write it into the new file without a header, the code would be a
Hi Tamil,
Thank you. I tested your suggestion and found that it was required for me to check the Contains Header checkbox in the CSV/TXT Open action for the output CSV file to not include the column headers.
I have another question. You suggested that I use the Log to File action to write the output CSV, however doing it this way requires that you add every column index from the CsvTxtRow record variable into the Enter text to log field for the action. Some of the CSV files that I need to remove the header will have over 80 columns, which would be very difficult and time-consuming to add each column one-by-one to the log to file action. Do you know of a way to loop through every column in the record variable so I don't have to specify each one to be written? I hope that makes sense.
Thanks,
Jack
Hi Tamil,
I figured out how to loop each value in a record and was able to output the CSV file without needing to specify each column in the log to file action. Thanks for your help.
Jack
Hi @Jack Dawson ,
I agree, that having more fields to update into the logs will be a lot of time to enter. However you can use the delimiter as a new line and use/assign the one variable is also good one
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.