I’m trying to save the Data Table after Data Scraping to a csv file. But as a result I get all values of a line in one cell separated by a comma. The file is written using Write CSV, the delimiter is a comma.
I will be grateful for any ideas!
CSV does not always mean comma separated. Sometimes it’s semicolon. Check what the separator should be on your system
Change the separator in all .csv text files
- In Microsoft Windows, click the Start button, and then click Control Panel .
- Open the dialog box for changing Regional and Language settings.
- Type a new separator in the List separator box.
- Click OK twice.
Just a little trick for some additional info:
You can add a row at the top to tell the system to separate the file by a specific character.
—you can look this up online too incase I am wrong on syntax
Excel will see that first line and delimit the file accordingly.
Although, this probably isn’t the most ideal solution in most cases, but is a trick I have used before.
I am reading a CSV file, and I am trying to write it back. Can someone explain why is doing nothing?
Hi @Fer, can you give a little more information on how you are trying to write the csv back and what errors you are seeing when you attempt to? If you are literally getting no output and have no errors, perhaps you should verify that the data you’re attempting to write out is actually in the object (a simple way is to use an ‘Output Data Table’ activity for a Data Table and enter the variable you’ve created into a ‘Write Line’ activity). I’d also suggest making verifying your variables.
If you post the csv (or at least a sample) and the xaml file, we can take a better look
csvFile.xlsx (9.3 KB)
Since I could not upload the file as CSV, I converted to Excel file.
What I want is to read columns A and B. And write the concatenation value into column C. All this in a CSV file.
I have 2 variables: csvDT (System.Data.Datatable) and LinhaCSV (Int32 - gives the row of the csv table).
Here is the workflow that I have:
I want to concatenate the value of row(0).ToString and row(1).ToString into row(2).ToString.
It does not return any error but does not write into csv file as well
Please refer to attached code and let me know it goes.
Thanks for providing that and I see you already got a couple of replies. I just wanted to point out a few things I saw in what you were doing that should be helpful to you going forward.
First, you should be using “For Each Row” rather than “For Each” to iterate through your Data Table. Using “For Each” means you will be referencing specific characters in a string rather than a specific column of data. So, for instance, if the first row contains “Hello,” and you referenced it using row(0).ToString, you will only return the letter “H” instead of the entire string “Hello.”
Another issue I see is that you aren’t assigning the string concatenation to anything other than writing it out, which means the Data Table is unchanged. If you want to update a value then you should make an assignment to the Data Table column that you would like to change. For what you’re wanting to do, you would need to have a variable that you can use to store the data you are concatenating and then use “Add Data Row” to add a new row to the Data Table with that value.
What @rinki provided should give you a good idea of what to do but I wanted to address the issues that I saw so you would know what may have been causing what you were seeing. I’m not sure why you weren’t getting any output, as it looks like you should have gotten the same exact data as your input, but I hope this helps.