writing in a shorter string to file
Hi, I have a problem:
I have a file in which I write things. the problem is that I don't want to add the string with data in the things that are already written. I want to crush it. the problem is when string that I really want to write is shorter than that which is already written. cause after writing I will get new string + "the tail of the previous. where, for the "tail", I understand the characters after the new string. Maybe it'll be clearer when I shows an example:
It is written in a file:
1; 2; 3; 555; 6; 7
and I want to write:
0; 0; 1; 4
and after writing, I'll take:
0; 0; 1; 455; 6; 7
This is the code I use:
DataOutputStream _dos; try{ _dos = returnFIle().openDataOutputStream(); //gdzie w stringBuffer sa wlasnie te dane ktore chce zapisac _dos.write(_stringBuffer.toString().getBytes()); _dos.flush(); _dos.close(); }catch(Exception e){}
can anyone suggest me how can I do so that it would be written:
0; 0; 1; 4
Instead of:
0; 0; 1; 455; 6; 7
PS.
I know that I can delete the file and create again before each entry, but it's rather unexceptable cause another program also uses this file.
I would be grateful for any suggestions,
concerning
Tags: BlackBerry Developers
Similar Questions
-
Incorporate the binary string in the string spreadsheet file
Hello LabVIEW wizards...
So I use scripture to VI file spreadsheet to create a beautiful layout, tabs-delimited report of one of my programs for the acquisition of data file. In one of the cells in the resulting worksheet file that I want to put a binary string of all my control values so when you open the data file all the control parameters used for its manufacture are restored, but the string is hidden when the report is displayed in Excel.
The problem is that the binary string flattened uses tabs and returns as part of its syntax the Spreadsheet File this VI to Write it's going in all directions. Worse yet, I can't unflatten chain when I open the file text because of "corrupt data or unexpected".
If I concatenate the string flattened with quotes around it she is superb and is placed in a single cell in Excel, but when I open the file in LabVIEW that she is still several elements in the array. I've isolated the binary string using the file VI text reading and got a subset of the quoted string, but it still unflatten correctly.
Essentially, I need to know how to get LabVIEW to pull a string literal full of special characters into a spreadsheet file and it unflatten. Any gurus what help you can provide is greatly appreciated.
Thank you
Jordan
Jordan
I suggest that you change the formatting of your chain shipped by replacing the tabs and returns with other characters that are not considered as commands by the spreadsheet functions. Without knowing how you represent your control binary values, I can't offer specific characters.
If two non-printable characters exist which do not appear in the control data, it's easy: just find and replace tabs and returns with those characters. If there is no character, then something more complex needs to be done for example to escape special characters. Or create two subVIs - one to remove the tabs and returns before writing the string in the file and the other to restore after reading.
Lynn
-
Converts a string fragment file values
Function wich use to convert the string fragment values?
I have this string in the file:
Instrument: NOR-DAQ; Date: 01-10-2008;
Quantity: voltage [V];
Results: 1.23,3.45,5.65,6.89,...;And I need to values - 1.23,3.45,5.65,6.89
Hi crisdragon,
You must use the native LabVIEW file and the string API.
I gave you an example.
Hope this helps.
-
Error with writing on an express measure VI file
Who is surprised? Not me.
I'm writing a VI that is extremely easy to use for controlling a large linear actuator. The objective here is to get this done and ready to use in less time as possible. I'm having an error appear on the writing of file express VI measure every time I try to collect data that are present as follows:
It seems not that I am adding multiple types of data in the file, but with express screws I usually do some voodoo magic to grow. Any thoughts on how I could fix this?
Thank you!
When you stop the application because you destroy the queue as soon as the producer ceases, you will get an error on your Dequeue. You should do this when the consumer stops. And to be more exact, you can send a command through the queue telling the consumer to stop. This would eliminate this local variable and make sure that you sign in fact everything you're supposed to.
I also recommend that you create the file before the loop of consumer and just use the TDMS functions for writing your data. Makes things more efficient and easier to understand.
See the attached updated help.
-
Simple problem writing ' # n/a "in a txt file.
Hello
I would like to write the string: # n/a, in a text file so that when I open the text file whith Excel, these points do not appear on the ground. Whith the VI I joined, these points # n/a are considered to be 0 on the ground of excel. Whereas if I write directly in excel # n/a (without use of Labview), it works fine. I only noticed that through my program "# n/a ' apperas on the left of the cell in excel, so that when entered directly that it is centered. I guess I use the wrong format or something like that, but I can't find the solution.
Anyhelp would be great,
XP & 8.5
Kind regards
Marc
I would use the Select function and a function of Format string in singles.
-
Writing table filled with enums to file
Hey guys
I learned a lot since the last comments in this forum, so I ask you once more. Correctly, it is still another question trival, but I am also willing to learn.
A little recap: Im using a MANUAL to control a search facility using im. Now, I want to put movies in the queue for special experiences. I did the code that does this and it works fine. Basically, I make a table full of enumerations that describe my State and the queue each enum using a loop for.
For sequences 'hardcoded' approach above is fine, but if I want to make custom sequences how would we all. Using what I learned the last time I did the code attached. It can make tables custom buttons to the predetermined sequences imput. When im done, I want to write a file documentation, but rather than write what is in my enum the sequnece, he writes the number corrosponding. While it is not impossible to decode, if feels rather clumsy. Can anyone solve the problem of writing in the file properly or suggest a different and better approach
Kind regards
Atamsih
Hi Atamsih,
Yes, FormatIntoString does not allow arrays as input. But you can use a loop FOR:
Start Tutorial: http://www.ni.com/gettingstarted/labviewbasics/
-
writing from the end of the file - FileConnection or PrintOutPutStream
Hi all
Im a new developer of blackberry and I were assigned to make a newspaper for the app I'm working on. The newspaper is supposed to be written to a file, but whenever the application is run, the new content is not meant to replace the old.
The thing is that I have not found an outputStream or a method that allows me to move the cursor to the end of the file, so I can start writing something new without crushing the old.
So two questions in one:
If I said:
fileCon = (FileConnection) Connector.open (_filePath, Connector.WRITE);
Fact writing status measures me which the OutPutStream I get from fileCon.openDataOutputStream (); will have his slider at the end of the file?If this is not the case, can you please tell me if there is a way to do this?
Thanks in advance
Claudio VeasTo add to a file, open the outputStream with a parameter that specifies the length of the file. This will put the cursor at the end of the file.
Somethng lik this:
FC = (FileConnection) Connector.open (fn);
If (! fc.exists ())
FC. Create();
int size = (int) fc.fileSize ();
OutputStream os = null;
If (size > 0)
OS = fc.openOutputStream (fileSize);
on the other
OS = fc.openOutputStream ();
Return (OS);Rab
-
How to read a string of file &; assign val to a variable in the batch file
Hello
How to read a string from a file and assign the value to a variable, then return the value on the screen in the windows batch file?
Any suggestions?
Thank you.Try again with
off @echo
for /F "delims =" % in ('findstr /i OPEN status.log") set var = %% a
% Var Echo% -
Writing and reading the same excel file
Hello.
I wanted to write a few values in the excel sheet and after doing some math here I want to read the same file.
Can I do this? Or there is a better way to accomplish the same task.
Kindly help.
Thank you
To do this you don't need a file. See the attached example, I guess it will work
-
I'm new to LabVIEW and was thrown in the middle of a project, so I need to get a job quick code! Can someone help me understand why the VI I joined does not work? I want to have a text file that contains a list of integers that will be used to refer to specific elements in groupings within my program. I tried to follow an example that I found, but the output that should only be an array will come out as a Measurer. Any help would be great appreciated! Thank you!
First, we will explain the cause of your error: the reason why this is happening, is that you try to do two different things at the same time. You are auto-indexation of the table and you are trying to index the table inside the loop. When you wire up a table one to to loop the loop auto-index. LabVIEW sense knows how often to perform the loop - there is no need to wire to the N. Also, the wire inside the loop will be an instance of the element of the array, not the table. Thus, the wire inside the loop is a scalar. Thus, the reason for the cut wire - you cannot index a scalar.
Also, I'm not sure what you're trying to do with indexing of one of the elements of the cluster. The cluster is empty, so there is nothing to index. Without doubt, the file is there to tell you which items to remove from the table 'Amp2"of the cluster. If so, remember that automatic indexing works in two ways. If you connect a cable "out" on the edge of a loop that he auto-indexé it, which means that the output will be an array.
Please read the help of LabVIEW on automatic indexing.
Now, in light of all this, here's what your code should look like:
Note the use of the reading of spreadsheet files VI. It makes your life easier.
-
I wrote a VI to create and update a file as many times as necessary on any given day. Any other day, a new file is created which, from that day there will be updated every time that the VI is executed and so on. The problem is that when I run time VI, the first of a new day, that is to say when the file is created only data are written to the file and not the header data. When the file is added, the data header and regular data is successfully written to the file. Can someone tell me how to fix this? A copy of the VI that I wrote is attached.
Thank you
Chuck M.
You had written header information when it was not an existing file, and then you overwrote this file with another file consisting only of data because you wired the "add to the file? (new file:F)' the same for the two functions (F requires to create a new file). I put the write function header in a structure of business because you only want to run when it comes to a new file (otherwise it will overwrite what's there). Wire the straight path through the case of forgery. I plugged a REAL data entry function to always add (because there's always a file at the time wherever the program there).
Jim
PS - a few other comments
- Avoid structures of the sequence
- You don't need the property node
- Use the features of path (no chain)
-
writing of XML in an .exe file
Hello
So, is it possible to display PHP in an .exe file instead of a .swf in a browser?
If so, how? I thought that if you just created the .exe on the server with the .php file in the same folder
He would read and work very well.
This doesn't seem to be the case... of ideas? Must always go through a browser page?
Thank you
It is possible to call a PHP file from an EXE file. Make sure you have th PHP file in the root Web of your Web server (IIS or Apache). Also, make sure you use the path of the server, for example: http://localhost/myapp/myphpfile.php. It should work!
-
Writing data in the text file or excel spreadsheet
Hello
I have a silly question to ask questions about the writing of data in a text file or a spreadsheet. I have an example that simulates a sine-swept DAQmx. The output it provides is the (amplitude and phase) frequency response function that is plotted on a graph (see VI) attached. I like to use these data for further analysis by transmitting the data to a text file or a spreadsheet. I've tried a few things, but the thread is broken. I guess I use the sink badly - so I was wondering, can you please advise me on what sink should I use?
Your help would be very appreciated,
Thank you very much
REDA
The wire is broken, because you cannot connect this type of data to one of these two functions. The data source type is a table 1 d of the clusters, where each cluster contains two tables. The text file write accepts strings, not clusters. Writing on a file action accepts dynamic data, and while you can convert dynamic data tables, there is no built-in mechanism to convert a table 1 d of the clusters of two matrices.
What you need to do is to convert the data in a format which can be accepted by these functions. Since you want to have a "spreadsheet" file then you should use writing to the spreadsheet file that creates a delimited text file. Since the frequency data would be the same for the plot of the magnitude and phase diagrams, you can have 3 columns: frequency, amplitude, and phase. You can take off the items using Unbundle by name, and then create a table 2D of each element of the cluster. The real question is to know if you want to save the data at each iteration and if you simply add on the file. The attached figure shows write an initial header and then adding just streaming the data.
-
Error 116 when a string of binary file reading
I try to use the 'writing on a binary' and "binary file reading" pair of VI to write a string to a binary file and read it again. The file is created successfully and a hex editor confirms that the file contains what is expected (a header + chain). However, when I try to read the string back once again, I received an error 116: "LabVIEW: Unflatten or stream of bytes read operation failed due to corrupted, unexpected or truncated data.» A quirk I found though, is that if I put "endianness" to "Big-Endian, network order", the error disappears when I use "native, welcome the order" (my original setting) or "little-endian" error occurs. Did I miss something in the documentation indicating that you can use big endian order when writing of strings, I do something wrong, or is this a bug in Labview? Because the program that it will be used for is to write large networks, in addition to channels, I would like to be able to stick to the 'native' setting for speed purposes and must not mix "endianness".
I have attached a VI of example that illustrates this problem.
I'm using Labview 8.5 on Windows XP SP2.
Thank you
Kevin
Hello
Please contact National Instruments! I checked the behavior that you have met and agree that it is a bug, it has been reported to R & D (CAR # 130314) for further investigation. As you have already understood possible workaround is to use the Big-Endian parameter. Also, I am enclosing another example that converts the string to a binary array before writing to the file, and then converts to a string according to the playback of the file. Please let me know if you have any questions after looking at this example though and I'll be happy to help you! Thank you very much for the comments!
-
unexpected empty cells in the worksheet after writing file
I'm writing dummy data to the excel file and notice that there are blanks in the file as below. How I avoid this?
10:10:07
10
0
1
2
3
4
10:10:07
20
0
1
2
3
4
10:10:07
30
0
1
2
3
4
10:10:07
40
0
1
2
3
4
10:10:07
50
0
1
2
3
4
10:10:07
10
0
1
2
3
4
10:10:07
20
0
1
2
3
4
10:10:07
30
0
1
2
3
4
10:10:07
40
0
1
2
3
4
10:10:07
50
0
1
2
3
4
Did you do that?
Maybe you are looking for
-
Can I continue my studies of software engineering with 8 GB of RAM in my retina i5?
Please can someone quickly comment!
-
screen touch iPhone 6 is best described as possessed
iPhone 6 - 9.2.1 When I try to text, my keyboard is doing crazy things. Examples: If I reply to a picture that someone sent me, it take me off of the screen keyboard and open the photo. The cursor will just come back in the middle of a sentence and
-
I follow the instructions on the removal and reinstallation. It says that I have a copy of the file in google chrome to keep the installed flashplayer to update or stop a grave permanently down. I use it mainly with the iPlayer. After having re-insta
-
WMP always updated on openeing
Why wmp always up-to-date at the opening?
-
authenticate vista after repairs
I had to fix my computer laptop girls with a new motherboard and now it tells me that we need to authenticate its key of vista and it won't let me. the laptop came with vist and microsoft is registered under my name. How can I turn it back on it so i