CSV Writer Problem

I have a column formatted as string with following format:
19:27:09.8268

The CSV Writer truncates the string like this:
27:09.8

I would think that since the data is formatted as a string that delimiters would not affect the CSV Writer. Any help is much appreciated. BTW - the Excel Writer works fine.

Hey rfeigel,

I just created myself a workflow with a column with the mentioned value which I write out with the CSV Writer (with default settings) and it works perfectly fine for me. Which version are you using? Would it be possible for you to create a minimal working example workflow to show the issue?

Best regards
Lars

2 Likes

@rfeigel same with me as @laaaarsi says. Maybe you could demonstrate your problem like this:

2 Likes

I have the same problem with the workflow you sent. I’m running Knime 4.5.1.

I opened the CSV file my workflow produces with Notepad and the string is correct. The problem happens when I open it in Excel.

Hi @rfeigel , I was just about to ask you how you figure that the CSV Writer was truncating the string.

Viewing a CSV file via notepad is the best verification, and you just confirmed that it looks good. So the CSV Writer is NOT truncating anything.

If you are opening the file in Excel, it’s usually a display thing or a conversion that Excel is doing (it’s assuming some type).

Try to force the CSV Writer to enclose all string in quotes, maybe Excel will see everything within the quotes as a string.

EDIT: Why are you saving the results as a csv if you want to read it in Excel? If you are going to read it in Excel, then use the Excel Reader. You would use the csv format as an exported data to be imported into another system.

1 Like

I do have an Excel writer which works perfectly. I want an CSV file to able to import to other systems. I tried enclosing everything in quotes which didn’t help.

Hi @rfeigel , ok so you are using both the Excel Writer and CSV Writer, correct?

You can use Excel to view what the Excel Writer created. For the csv, don’t mind what Excel is showing you for the csv file. It’s what’s in the notepad that’s the real data, so your csv file has the correct data which you will be able to use for import.

1 Like

Thanks. I should have figured that out. Problem solved.

1 Like

@rfeigel I know CSV is a very common file format to transfer data but it comes with these kinds of problems. Depending on the target system you might think about other data formats like Parquet or ARFF (which is also ‚pure‘ text but keeps the column types intact), both are supported by KNIME. Or even SQLite/H2 if the other system would support them.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.