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.