spilleravr Posted May 13, 2016 Report Share Posted May 13, 2016 Hey once again, I got another problem and cant figure out why is this happening. I want to write 30 values to a txt file in CSV format. The values are being written but the carriage return does not work (or so I think atleast). It writes the stuff on the next line, but no in the beginning of the line. I attached a txt file and part of the vlp file as a picture (original file was too large to be uploaded). Maybe someone can suggest me anything. Thanks in advance, T Cant add more than 60kB, will add when the post gets reviewed. LOG.TXT Link to comment Share on other sites More sharing options...
s.pratt Posted May 13, 2016 Report Share Posted May 13, 2016 Hello, How do you have the SD create delimited line set up? Did you only write one line in the TXT file provided? Link to comment Share on other sites More sharing options...
spilleravr Posted May 13, 2016 Author Report Share Posted May 13, 2016 Hello, How do you have the SD create delimited line set up? Did you only write one line in the TXT file provided? Hey, i did write one line in the file. The last value had a delimiter of CR and LF. Attached a picture of the setup. http://postimg.org/image/47tghgbsx/ http://postimg.org/image/9bps2rt8h/ http://postimg.org/image/vxv3fi6yp/ Link to comment Share on other sites More sharing options...
s.pratt Posted May 13, 2016 Report Share Posted May 13, 2016 Hello, You do have the CR and LF characters after the last piece of data. If you write a second line, you should see the line be written below the first line in the TXT file. They will not show on the TXT file since they are "invisible" characters and there is no way for the TXT file to show these characters. Please let me know if you do not find this to be the case. Hope this helps. Link to comment Share on other sites More sharing options...
spilleravr Posted May 13, 2016 Author Report Share Posted May 13, 2016 Hello, You do have the CR and LF characters after the last piece of data. If you write a second line, you should see the line be written below the first line in the TXT file. They will not show on the TXT file since they are "invisible" characters and there is no way for the TXT file to show these characters. Please let me know if you do not find this to be the case. Hope this helps. You are totally right! I just imported the txt file to excel and the structure is the way I wanted. Nice, thanks a bunch! One more thing tho, any suggestions how to add a header row to the txt file? I tried to add a header row using SB2 in the beginning of the Main Routine, did not work. The header row got overwritten in the routine, where I write the values. I thought it opens the file, writes the header, leaves the pointer there and when I later want to write more then it will start from the pointer. So, append is the word im looking for. Any suggestions? Link to comment Share on other sites More sharing options...
s.pratt Posted May 13, 2016 Report Share Posted May 13, 2016 Writing a header upon start-up may be too quick for the PLC to write to the SD card - I don't think it ever receives that command. We have an example of writing a header to the CSV file in the Examples of VisiLogic. (Help tab\Examples...\Version 900\Project Examples\SD\V570_buffered CSV.vlp) In this example, when we request to write a CSV line, we first write the header to the file once, then we create the data lines and write them. This should work for you. Please let me know if I can explain anything further. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now