Jump to content

Porter

Members
  • Posts

    231
  • Joined

  • Last visited

  • Days Won

    27

Everything posted by Porter

  1. Thanks for the info Phillip. It's unfortunate that I didn't find your post earlier. Your VI is about 8 times faster than mine. Converting to a byte array and replacing CR/LF with ASCII record separators and commas with ASCII unit separators is a very good idea. Using indexed for loops instead of while loops to build the array must also make a big difference. I was also using trim white space on every cell which is actually not correct. I modified your VI slightly to fit my application: - removed file open and path input/output (I don't want that functionality) - added support for field delimiters other than the comma. Tested with tab and semicolon. - force all end of lines to LF before processing. This avoids causing a blank row from a CR+LF. Would you like me to post the modified VI here?
  2. After many frustrating experiences with patched together CSV parsers (admittedly of my own creation), I've finally broken down and developed a CSV file parser that follows the RFC-4180 format: http://tools.ietf.org/html/rfc4180 That is to take into account double quotes and commas inside double quotes and multiple-line entries. This is essential if you plan on storing user-input text data or storing numbers that may have a comma as a decimal point. From what I can tell, this is the same format that Open Office, Libre Office and Microsoft Excel use for their CSV file export. Therefore, using this format, you can export from LabVIEW to CSV, open it in Excel, make changes, export from Excel to CSV then import it back to LabVIEW without everything being broken by a missing double quotation mark or an extra comma. Attached is the VI to parse a CSV formatted string to a 2D array of strings for LV 2013, 2012 and 8.6. I've also attached an example CSV file (inside Test1.zip) exported from LibreOffice to demonstrate some of the tricky cases that most CSV parsers can't handle. Please give it a try and let me know your thoughts. Update: I've posted the finished library to the Code Repository Database & File IO catagory here http://lavag.org/files/file/239-robust-csv/
  3. I was looking for a way to simply pass status messages from anywhere in my application to a log file and/or a status message box on my user interface without having to pass a queue reference or event reference everywhere. I wanted something like the good old printf() command that I could litter throughout my application. I also wanted something that didn't take much place on the block diagram. This is what I came up with. This VI sends the message string along with a time stamp and the call-chain to listeners of the "stdout" event (only if the specified verbose level less than or equal to the globally set verbose level). The message received by the stdout event handler is an instance of the "LV_Printf Msg" class. The data is available though property nodes or it can be flattened to a string through the dynamically dispatched "Receive Message" method. You can create a child of this class and override the "Receive Message" method to format the message differently. Please try it out and let me know your thoughts. Source & Example Usage - LabVIEW 2013: LV_Printf - 2013.zip Source & Example Usage - LabVIEW 2011 (not tested): LV_Printf - 2011.zip
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.