LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I remove the last row in a csv data file

I would like to remove the last row of data from a csv file that I have saved.  I can identify the start byte of the last row; however, I'm not sure what tool is the best one to remove it.  Should I move the EOF?  Should I open the file up to that point then save over the old one?  Is there another way I don't know about?  I am using labview 7.1.
 
Thanks
0 Kudos
Message 1 of 10
(7,546 Views)
Setting the EOF should work. Just make sure you have a backup of the file before you try. Smiley Wink
Message 2 of 10
(7,536 Views)
Thanks!
0 Kudos
Message 3 of 10
(7,512 Views)

I am using LV2013 and need to do this but am having trouble.csv files are a new thing for me and I am a bit of a beginner. I am saving data row by row every time the operator fills a number of fields and clicks a commit control. But I also want a "remove last entry" control on my front panel in case the operator makes a mistake and wants to delete the last entry. Any suggestions would be very welcome.

Karl

0 Kudos
Message 4 of 10
(7,183 Views)

Actually, I think I just nutted out a way:

 

 

It seems to work and is a lot simpler than I thought it would be, but if anyone has a better way I would love to hear it.

Cheers

0 Kudos
Message 5 of 10
(7,169 Views)

I would use the Read Text File.  You can right-click on it and tell it to read lines.  Then Delete From Array.  Leave the index and length unwired and it will delete the last item (I noticed your code is removing the second line).  Then open the file again set to replace or create and write your data.  This method allows you to propagate your errors instead of the Write/Read Spreadsheet File handling the errors for you.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(7,154 Views)

Thanks Crossrulz, that is an easier to understand way of doing it. Those spreadsheet VI's are kinda crowded and the help for them doesn't have examples so its easy to miss things like that. My fish weighing and measuring application is working a treat now. Thanks again.

0 Kudos
Message 7 of 10
(7,122 Views)

@KarlosAmigos wrote:

My fish weighing and measuring application is working a treat now.


This is off topic, but can you expand a bit on your application? I've done some work in this area, so it would be interesting to hear what other people have done.


___________________
Try to take over the world!
0 Kudos
Message 8 of 10
(7,109 Views)

hi tst, We tag Barramundi in a research environment and do nutrition research for use in fish farming and aquaculture. Each fish has an RF ID tag in it to identify it. We pull them out of the pond and then scan them, weigh them and measure their length before returning them to the water.

So, what we did was build a waterproof box with an Aten USB to Serial hub inside it. Four serial ports can now be plugged into any computer. The scales, the measuring board and the scanner were all bought off the shelf. They all have a serial interface and can communicate with the LV app with VISA functions. A config file contains all the com port info.

 

On the front panel, each measurement can be aquired automatically or entered manually. Each field has a blank check (which can be switched off) to make sure nothing gets left out. Once all the fields are full, each fish's record is then sent to a csv file with a time/date stamp. If you screw up a measurement, you can now delete the last row from the file, hence my question above. Not all of the code is mine in this application, a colleague of mine did a similar thing for salmon many years ago using LV 7.1 and it worked well but was in dire need of modernisation and some more features and user friendliness.

Message 9 of 10
(7,080 Views)

OK, so not exactly the same. Our work in this area has been in industry, both in outdoor growing ponds and in processing plants. I remember that we also talked with some research stations about various things, but I don't think we ever actually did something with any of them.


___________________
Try to take over the world!
0 Kudos
Message 10 of 10
(7,064 Views)