regex problem: convert CSV to comma delimited

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: regex problem: convert CSV to comma delimited

Post by FourthWorld » Fri Jul 25, 2014 9:11 pm

Seems to be an unfortunate convention: techies love TLAs (three-letter acronyms) so much that "CSV" has become somewhat generic for referring to any flat delimited formats, even those that don't actually separate values with commas at all.

I haven't used Excel in many years since I switched to Libre Office, but I think they may have similar options for export in terms of being able to both choose tab as the delimiter and turn off the option of adding quotes for textual values.

With that output you can use the data in LC directly very efficiently, parsing by setting the itemdel to tab and displaying in a simple field object with the hGrid and vGrid set to true.

And yep, I was very active in the HyperCard community, going back even before the Web was invented to the old CompuServe days. Nice to be remembered - thanks.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: regex problem: convert CSV to comma delimited

Post by kaveh1000 » Fri Jul 25, 2014 10:27 pm

Richard, I think you might have solved another problem and I can go back to TSV. I had been trying to display the data in a datagrid, but it was just too complex. I had no idea about hgrid and vgrid. I will now investigate. Does a tab move data into a new cell? How do you show the data correctly in a field with hgrid and vgrid on?
Kaveh

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: regex problem: convert CSV to comma delimited

Post by richmond62 » Fri Jul 25, 2014 10:29 pm

As LibreOffice is, effectively, a clone of Microsoft Office, LibreOffice Calc is very close to Excel.

Today I wanted to export a TAB delimited text file (ending in .csv) from LibreOffice; but couldn't find out
how to do it. However I found instructions on how to do this for Excel on the internet; and followed those instructions
to do it from Calc.

LibreOffice Calc allows you to delimit your textfile with whatever you want, so there should be no need (as long as you have access
to a copy of Calc (which WILL parse Excel fines)) to work out fancy and convoluted routines in Livecode to differentiate between when a QUOTE is a "
and not a delimiter.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: regex problem: convert CSV to comma delimited

Post by richmond62 » Fri Jul 25, 2014 10:31 pm

"I had been trying to display the data in a datagrid, but it was just too complex."

Indeed it is: but a Table Field will take care of a delimited text field quite acceptably.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: regex problem: convert CSV to comma delimited

Post by richmond62 » Fri Jul 25, 2014 10:39 pm

This chap seems to know what he's doing:

http://www.codingmonkeys.com/index.php?topic=2398.0

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: regex problem: convert CSV to comma delimited

Post by kaveh1000 » Fri Jul 25, 2014 10:45 pm

Guys, you have all been incredibly helpful. I am giving a live demo of a software next week, made using LiveCode, and it's going to look much smarter now hopefully. :-)
Kaveh

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: regex problem: convert CSV to comma delimited

Post by Simon » Sat Jul 26, 2014 3:05 am

Heck, tossing all your data out the window and hitting yourself with a hammer is better than CSV. ;)
LMAO

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply