CSV/Merge issues & testing analysis

I’m running Ubuntu with LB for my laser, and I’m attempting to do a basic CSV/Merge operation.

I’ve encountered some odd CSV behavior and wanted to share in case this is a bug, and also because I need to understand how to properly format a CSV (some values contain commas).

My LB setup is pretty simple - just 4 textboxes. %0, %1, %2, %3. All set to Merge, and offset 0.


Scenario 1
CSV:
“Test r1c1”, “Test r1c2”
“Test r2c1”, “Test r2c2”
“Test r3c1”, “Test r3c2”
“Test r4c1”, “Test r4c2”

File loads, no errors.

Output:
%0 = Test r1c1
%1 = Test r1c2
Test r2c1
%2 = Test r2c2
Test r3c1
%3 = Test r3c2
Test r4c1

Issue:
%0 looks fine
%1 contains two values (as two lines) and should only contain 1… and contains data from two different rows.
%2 and %3 should be blank - there’s not even a column… This is very similar to %1, and I would expect this would go on indefinitely if I had more variables and more rows in the CSV.


Scenario 2
CSV:
Test r1c1, Test r1c2
Test r2c1, Test r2c2
Test r3c1, Test r3c2
Test r4c1, Test r4c2

File loads, no errors.

Output:
%0 = Test r1c1
%1 = Test r1c2
Next row button
%0 = Test r2c1
%1 = Test r2c2

Issue:
Everything works as fine, however I cannot have values with a comma in them.


Scenario 3
CSV:
Test r1c1, Test r1c2
“Test r2c1”, “Test r2c2”
“Test r3c1”, “Test r3c2”
“Test r4c1”, “Test r4c2”

File fails to load - “Error on line 1”

Issue:
File fails to load, and is technically still a valid CSV.

CSV’s CAN contain only a single value in quotes (values that have spaces and/or escapable characters such as commas in them).

This is also a common approach when the first row is a header - the header may not have quotes, but the data may.


Note: Not sure if this issue is limited to just Linux, or also affects Windows, as my machine that controls the laser doesn’t run Windows, and haven’t tested it offline on my Windows machine yet…

I suspect you may find some processing errors in your mutiline CSV output, or how you are handling quotes.

In an ideal world, quotes would be handled as values, and there would be an escape sequence to include double quotes within the values as well - what i’ve commonly seenis either double-double quotes i.e. “” or " as an escape to include a double quote within the value.

CSV processing can definitely be a pain, and I’ve even seen several programming libraries dedicated to it’s oddities. Hopefully some of this testing helps!

Please let me know if I can provide anything further, but in my use case, I do have some values that contain commas and would like to be able to load a CSV file with commas in the values.

Variable Text Formatting - LightBurn Software Documentation

Any sequence of characters enclosed in single quotes will be included verbatim in the output string (stripped of the quotes), even if it contains formatting characters. Two consecutive single quotes (‘’) are replaced by a single quote in the output. All other characters in the input string are included verbatim in the output string.

Thank you, I will try that.

I do suggest you review my scenarios however, as I still believe there could be an issue based on your feedback.

Double quotes are also being stripped in my examples, and additionally, the newline behavior is not as you described. It’s also odd that the double quotes work if they are in line 0, but the file errors if they are on line 1 or greater.

Also, single quotes are fine but just fyi, some software (such as Excel) use double quotes, not single quotes for their string escape characters.

I didn’t review your original post in depth to test the various scenarios but check this post and see if it applies to you:

I think you identified the issue. Using double quotes to escape commas is essentially exactly what is happening, and ignoring displaying the double quotes scattered elsewhere.

I would urge the same thing that was referenced in the post after that however, adhering to the RFC for how the CSV’s are typically formatted.

There are libraries for all of the major programming languages that handle the complexities of CSV’s.

Thank you for finding this post, which helps identify what I was seeing. I did use the search before I made my post, but didn’t seem to find these older posts.

Glad that’s applicable. I only knew to look for it since I was involved in the original conversation.

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