prads Posted May 30, 2008 Report Share Posted May 30, 2008 Hello, I want to write text into a text template file. For example, consider I open the template file which already has the following written in it: Name: DOB: Address: Phone: Now I have to write my name corresponding to the name field, and DOB,address,phone etc corresponding to its fields. When opened, it should look like: Name: Prads DOB: 10/10/2000 Address: 122 MyBlvd MyState 11111 Phone: 111-10101010 Can somebody tell me the VI's I got to use? How should I move precisely to the position where data has to be written next. I mean, say I have written the Name and DOB, and now Iam trying to write the address......How do i jump to the location pointer corresponding to the address field. Is there a VI or an example which calculates and correspondingly ignores those text which is already present so that I can write in the required position in the file? Thanks, prads Quote Link to comment
gleichman Posted May 30, 2008 Report Share Posted May 30, 2008 QUOTE (prads @ May 28 2008, 07:55 PM) Hello,I want to write text into a text template file. For example, consider I open the template file which already has the following written in it: Name: DOB: Address: Phone: Now I have to write my name corresponding to the name field, and DOB,address,phone etc corresponding to its fields. When opened, it should look like: Name: Prads DOB: 10/10/2000 Address: 122 MyBlvd MyState 11111 Phone: 111-10101010 Can somebody tell me the VI's I got to use? How should I move precisely to the position where data has to be written next. I mean, say I have written the Name and DOB, and now Iam trying to write the address......How do i jump to the location pointer corresponding to the address field. Is there a VI or an example which calculates and correspondingly ignores those text which is already present so that I can write in the required position in the file? Thanks, prads I have doubts about your question. You can't insert new data into the middle of an existing text file. If you want to use a text file template, you will have to read it, insert the new data (in memory) and then write it back to disk. You could use unusual characters to mark where text is to be inserted such as ASCII(255). Quote Link to comment
jgcode Posted May 30, 2008 Report Share Posted May 30, 2008 QUOTE (gleichman @ May 29 2008, 11:48 AM) I have doubts about your question. You can't insert new data into the middle of an existing text file. If you want to use a text file template, you will have to read it, insert the new data (in memory) and then write it back to disk. You could use unusual characters to mark where text is to be inserted such as ASCII(255). Yes that would be hard, but you could treat your data as arrays to overcome this. Try this... Download File:post-10325-1212038756.zip Code is in LV8.0 Quote Link to comment
prads Posted May 30, 2008 Author Report Share Posted May 30, 2008 QUOTE (jgcode @ May 29 2008, 12:27 AM) Yes that would be hard, but you could treat your data as arrays to overcome this.Try this... Code is in LV8.0 Oh wow the above code is excellent. However is that possible with Write to Text File.vi as well or only with Write to Spreadsheet File.vi? Thanks, prads Quote Link to comment
jgcode Posted May 30, 2008 Report Share Posted May 30, 2008 QUOTE (prads @ May 29 2008, 02:33 PM) Oh wow the above code is excellent. However is that possible with Write to Text File.vi as well or only with Write to Spreadsheet File.vi? Thanks, prads No worries Write to Spreadesheet uses the native Write to Text File VIs so yes....go for it! Quote Link to comment
prads Posted May 30, 2008 Author Report Share Posted May 30, 2008 QUOTE (jgcode @ May 29 2008, 05:01 AM) No worries Write to Spreadesheet uses the native Write to Text File VIs so yes....go for it! Hi, I have another small problem. In my implementation, the data file is a 1D array of string and the template is a 1D array of string. However when I use the build array.vi it still produces 1D array of string. Now the output of the build array does not let me connect to the Write to Spreadsheet File.vi's 2D input. So when I check the data.csv output file after running the code, it shows me my template completely first and then my input data. Somebody please help. regards, prads Quote Link to comment
prads Posted May 31, 2008 Author Report Share Posted May 31, 2008 Hello, I have a topic running in the path LAVA > Software & Hardware Discussions > LabVIEW (By Category) > Database and File IO. I started it in LabVIEW General section but perhaps the moderator moved me there. Nobody is answering my question in that section so i am posting it here again. Please excuse me. Please refer to the post "Writing to a template file" in the above section. Now that you know the status, here's my problem: I have used the same concept as in the example posted by jgcode. In my implementation, the data file is a 1D array of string and the template is a 1D array of string. However when I use the build array.vi it still produces 1D array of string. Now the output of the build array does not let me connect to the Write to Spreadsheet File.vi's 2D input. So when I check the data.csv output file after running the code, it shows me my template completely first and then my input data. Somebody please help. regards, prads Quote Link to comment
orko Posted June 1, 2008 Report Share Posted June 1, 2008 I would highly suggest looking at the context help window for your answer (concatenate inputs option). It will feed you for a lifetime Quote Link to comment
jgcode Posted June 1, 2008 Report Share Posted June 1, 2008 QUOTE (prads @ May 31 2008, 06:14 AM) In my implementation, the data file is a 1D array of string and the template is a 1D array of string. However when I use the build array.vi it still produces 1D array of string. Now the output of the build array does not let me connect to the Write to Spreadsheet File.vi's 2D input. So when I check the data.csv output file after running the code, it shows me my template completely first and then my input data. Somebody please help. You should take orko's good advise and search LabVIEW Help to easily answers such questions, as it will only benefit you in your LV personal development. However, if you are genuinely stuck below is the answer. Enjoy! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.