How to generate the .xls file which can be stored as .csv file?

Dear All,
         I want to generate a .csv file, but with the tab operated values.
         Currently I am generating the csv file with the csv option, but the data of the 16 channels, dont be the tab seperated and it stores all the 16-channel's data in single cell.
         Instead i want to generate a csv file, which can be tab seperated and it should store 16-channel's data in 16 continuous cell in a single row, and it must be the .csv file.
         This process is of course posiible to store the 16 channel's data into 16 continuous cell of row, but that file will be stored as .xls file, but customer requires the .csv file, so that it can read the csv file directly into their software.
Thanks in Advance,
x9561 (148438)
2/23/2007 11:40:09 AM
comp.lang.labview 35210 articles. 1 followers. vasusachin24 (1) is leader. Post Follow

3 Replies

Similar Articles

[PageSpeed] 11

You've made an extremely easy task much more difficult. If you create a file with the .csv extension, then you should actually use a comma as a separator instead of a tab. Excel assumes a comma when reading a .csv file. In the frame where you do the array indexing, number to string, concantanate to string - all can be replaced with TWO functions. You can wire an array of numerics into a single Number to Fractional String and then wire the output to an Array to Spreadsheet String function. Replace that mess you have with the code below and you will have an actual csv file that Excel will read correctly and each value will be put into its own cell.
You've got some other things in your program that don't make much sense either. Like the two stop buttons where one is wired to the LabVIEW Stop function and I don't understand why you are converting the process values to dbl when the data you are reading is I32. Also, since you have 7.1 and are using VISA, get rid of the old serial compatability functions (which use VISA anyway) and maybe add some error checking.
<img src="http://forums.ni.com/attachments/ni/170/231738/1/Save%20as%20csv.PNG"> Message Edited by Dennis Knutson on 02-23-2007  07:51 AM

Save as csv.PNG:
http://forums.ni.com/attachments/ni/170/231738/1/Save as csv.PNG
x9561 (148438)
2/23/2007 3:10:09 PM
Hiii Dennis,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; It works even without using the number to fractional string, thanks very much.
x9561 (148438)
2/24/2007 5:10:13 AM
In addition to what Dennis mentioned, there are quite a few other mistakes in your program, for example:

- You open the file outside the loop and then continue to write inside frame #2 of the stacked sequence and close (!) the file after the case structure (still inside the while loop). This means that at the second iteration the writing will fail. Your code wil never know, because you don't use the error information for anything useful. Solution: Place the "close file" outside the while loop on the right and wire the file reference and error cluster across in ALL cases. Never use any default output tunnels for file references! Stop the loop if an error occurs. (As Dennis already mentioned, get rid of "STOP" and the STOP node!! Stop your VI with the "Stop 2" button).

- You don't need any of the sequence structures because dataflow fully determines execution order once you use VISA. Simply use the error cluster to properly sequence the serial operations. Everything else already has data dependency.

- You might want to skip writing to the file in all the cases where the array is empty.

- When you initilize arrays with diagram&nbsp;constants it would make more sense to do that once outside the big loop and not with every iterations (sure the compiler might fold the code anyway, but still....).

- Be aware that .csv is not necessarly a good choice of you ever plan to use your code in certain european countries that use the comma as a decimal seperator.

- That small while loop in case 15 of one of the small case structures does a very simple operation way too convoluted. You could e.g. reshape to a Nx8 2D array and use an autoindexing FOR loop. ( no more splitting arrays, shift registers, comparison operations, etc.)

- ...

Good luck! :)
x9561 (148438)
2/24/2007 6:40:15 PM