Extra space in text file line
This one is not critical, just aesthetical. My program writes lots of lines of info into a text file. One section of my code seems to include an extra empty space at the beginning of the line. The text is correct, but it just looks awkward being one space off from all the other lines of text.
I will include a sample of the section of code writing to the text file. I didn't include all of my code, so parts of the sample I'm including will show errors, but you can get the gist of what I'm trying to do.
In the line that displays "Start time of switch setting", the text is moved one spot over. Why?
Amateur programmer for over 10 years!
Attachments:
space in first text file line - sample code.vi 28 KB
Yup, that seemed to do the trick! I never even tinkered with "edit format string" of my "format into string" tools. I just wired my strings into them and let 'er rip.
I ended up looking into the format of my other "format into string" tools in my program and they were set up the same - a space between each %s. But only that one "format into string" tool between string lines 5 and 6 did it actually place a space in the resulting text. Weird. Nowhere else did that occur.
Thanks for the help!
And tell me about desctructive kids!! I have 4 kids - all under the age of 6! I know all about toilets clogged by toys, lipstick smeared on walls, hand lotion all over just cleaned laundry, etc.
My brother worked at a govt. contractor for a few years until he moved on to bigger and better. Years later he was browsing the stock section of the newspaper and he was reminded that he still had some stock from that company. So he glanced at the stock value listed in the paper and found he had almost $10,000 just sitting there! He bought a beautiful new Martin acoustic. I love that guitar! I have an old Fender dreadnought acoustic. I took it once to a guitar dealer to trade it in. He looked at it and handed it back and told me I better hold on to it, it was worth more than I realized.
Probably not worth enough to put 4 kids through college though.
Amateur programmer for over 10 years!
Similar Messages
-
How to read the whole text file lines using FTP adapter
Hi all,
How to read the whole text file lines when error occured middle of the text file reading.
after it is not reading the remaining lines . how to read the whole text file using FTP adapter
pls can you help meYes there is you need to use the uniqueMessageSeparator property. Have a look at the following link for its implementation.
http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/adptr_file.htm#CIACDAAC
cheers
James -
How to read text file line by line...?
how to read text file line by line, but the linefeed is defined by user, return list of string, each line of file is a item of list?
please help me.
Thanks very muchBrynjar wrote:
In Groovy, you would do something like:
linefeed = "\n" //or "\r\n" if the user chose so
lines = new File('pathtofile').text.split("${linefeed}")This is one of the things that has always annoyed me about Sun's sdk, i.e. the lack of easy ways to do things like that. You always end up making your own utilities or use something like Apache's commons.io. Same goes for jdbc and xml - I'll wait for appropriate topics to show how easy that is in Groovy :)I generally agree, but what I really don't like about the Groovy text-file handling niceties: They don't care about encoding/always use the default encoding. And as soon as you want to specify the encoding, it gets a lot more complex (granted, it's still easier than in Java). -
Read from a text file line by line
Hi,
I am new to Labview and I am trying to output a text file line by line. For example if my text file is
START
SETRPM 1000
WAIT 10s
RAMP RPM linear,1000,2000,2 MAF linear,5,7,2
WAIT 5s
RAMP RPM sine,2000,1500,3 MAF sine,7,3,3
END
I want it to output
START
SETRPM 1000
SETMAF 5 ...and so on
I tried modifying this code provided by Altenbach but it is still not working as I want it to. Can anyone direct me toward how I can fix this?
Thank you!
Your program does exactly what you asked it to do. In particular, it will repeat 10 times, at one per second, reading (and storing in String) the (unchanging) data that you bring in on the Shift Register. This data will consist of the first line of the (assumed-)multi-line file you specified.
I suppose your question is "Why is it only showing me one line?" This is where it really pays to "Read the Directions Carefully" (or, in this case, carefully read the Help for Read from Text File).
Bob Schor
P.S. -- I pointed your code at a text file of 7 lines on my PC. When I made a few small changes (including doing away with the silly For loop that shows the same thing over and over) , I got out an array, size 7, containing the lines of text. -
Help! Extra one line space in text file???
halo, i am doing a program to download a created text file into pc... the download program is just retrieve records from database and write it into a text file... then i will pass that created text file name to another program, then it will prompt out the window message dialog box to allow user to save or to open the text file....
now i want to know what will cause one extra line at the top of the downloaded text file??
Here is my coding, assume the file name is file1...
response.setContentType("text");
response.setHeader("Content-Disposition","attachment;filename=" + file2);
int Read1; FileInputStream stream1 = null; try { File f = new File("c:/mysql/data/mrs/download/" + file2);
stream1 = new FileInputStream(f); while ((Read1 = stream1.read()) != -1){ out.write(Read1); }//end while out.flush(); }//end try</p> finally {</p> if (stream1 == null){
stream1.close();
}//end if</p>
}//end finally</p>response.setContentType("application/text");
response.setHeader("Content-Disposition","attachment; filename=\"" +fileName);
response.setContentLength((int)file.length());
OutputStream outputStream = response.getOutputStream();
FileInputStream stream = new FileInputStream(file);
BufferedInputStream bufferedInputStream = new BufferedInputStream(stream);
InputStream inputStream = new BufferedInputStream(bufferedInputStream);
int count;
byte buf[] = new byte[4096];
while ((count = inputStream.read(buf)) > -1)
outputStream.write(buf, 0, count);
inputStream.close();
outputStream.close(); -
Extra spaces in TEXT format report
hi
i have a report with in the text format, when i generate this report it is generating a space (as end of page) between the pages, and when i save the file as text file these spaces are still their.
how can we remove these spaces before generating the text file?? , i donot want to change on the text file after generating it
any tips??
Mahdi Chararahi
thank you for ur answer,
i removed the extra line space, but still i have a problem on this report, when it is opening in the text format thier is a junk character appearing instead of the page break, it is a small box with character symbol of "FF" , i donot know from where this character comming, how to remove it?
is there another way of opening the text result directly from the "view output" option other than opining it in the browser and then save as text?
Mahdi Charara -
How do I save/export as a TAB or SPACE delimited text file?
Just upgraded from Apple Works to iWorks. The only text exporting option I see is .csv. Comma separation really screws up my needs. Is there a way to export as plain text? TAB or SPACE delimited?
Why not using the good old
--[SCRIPT clipboard2textFile]
on run
set tsv to the clipboard as text
set nomDuFichier to (do shell script "date " & quote & "+P%Y%m%d-%H%M%S" & quote) & ".txt"
set p2d to path to documents folder as text
tell application "System Events"
make new file at end of folder p2d with properties {name:nomDuFichier, file type:"TEXT"}
end tell -- System Events
set leDoc to p2d & nomDuFichier
write tsv to file leDoc
end run
--[/SCRIPT]
I have it installed as:
<startupVolume>:Users:<my account>:Library:Scripts:clipboard2textFile.scpt
No need for an extra application.
Copy to clipboard,
trigger the script from the menu,
the text file is available on the desktop.
Yvan KOENIG (VALLAURIS, France.) lundi 24 août 2009 16:25:13 -
I can not remove spaces from TEXT file..
Hi All,
please advise me why the following code not remove the spaces or tab from the text file.
try
FileReader fr = new FileReader("D:\\Test\\a.txt");
BufferedReader br = new BufferedReader(fr);
Pattern p;
Matcher m;
String line;
String afterReplace = "";
String inputText = "";
while((line = br.readLine()) != null)
inputText = line;
p = Pattern.compile("\\s+|\t");
m = p.matcher(inputText);
System.out.println(afterReplace);
afterReplace = afterReplace + m.replaceAll(" ") + "\r\n";
System.out.println(afterReplace);
fr.close();
catch (Exception e){
System.err.println("Error: " + e.getMessage());
}my regards
Waelmany thanks for you , i try to used it for the following text but the results same.
McNair was shot and killed last weekend in what police say was a murder-suicide. (July 9) Nation / World By: AP
Comments: text ( 0 ) | video ( 0 ) + Add a comment
Be the first to add a comment .
1 2 3 4 5 Your Rating <br>
Popularity Your Name: Your Comment:
http://videos.kansascity.com/vmix_hosted_apps/p/media?id=4999903&item_index=&genre_id=00000840
Your Email: Friend's Email: Your Message:
Top Videos Nation / World
Sports Entertainment Business Lifestyle
Archive User Submitted Politics Ink Local
Selects
all Sort By: Most Recent Most Popular
Highest Rated Loading...
<br>
All users : If you have not already done so, Click "Record a Comment" to begin. Next, click "Allow" to use your camera.<br><br>
Additional Info for Mac users : If you do not see video (after clicking 'allow'), do the following:<br> Click on the blue "gear" icon in the lower right corner to bring up the settings window. Click on the webcam icon. If you are using a built in iSight camera,
choose USB Video Class Video from the pulldown menu. You should see video immediately.<br><br> Click "close" button.
Record! You must record at least ten seconds before
you can stop. -
How to check the content in a text file line
hi all,
i had the following problem:
There is a text file with multiple lines of data in it
The data comprises of characters, numbers and symbols
In this file, any line can be commented (till the end) by using symbol ';'(semi-colon)
Now i have to find the number of occurences of a symbol '$' in this data, such that
it should not exist in a commented line
One more limitation is that ';' (semi-colon) could occur at any position in a line, i.e., if this occured in the middle of the line, then all the following data in the line is taken to be as commented one and we have to skip it and move to next line.
Plz do help.
Regards,
santosh
Regards,
santoshHi santosh,
just a guess this is what you need.
Greets, Dave
Message Edited by daveTW on 09-15-2006 09:59 AM
Greets, Dave
Attachments:
search & count $.vi 13 KB
search & count $.png 10 KB -
How do I read a text file line by line and store to array
I have a text file, I want to be able to store each line of the file in an array, how would I go about doing this? code example? tutorial? Thank you
Well, you got the pseudo code:
a) read line
b) add to array
So whats the problem? What don't you know how to do?
What does your text book tell you about reading files. I'm sure it has an example, every book I've read does.
By the way I would use an ArrayList to store each line of text, that way you don't need to know in advance. -
Need one space between text and line color
Is there any way to offset the text from the border a bit? I
would like to have a black line around some boilerplate text,
but the text is always butted against the border. Is there a
way to offset the text a bitHamidHelal wrote:
Lan_Desu wrote:
Please, help me.
Is there any way to offset the text from the border a bit?
I would like to have a black line around some boilerplate text, but the text is always butted against the border. Is there a way to offset the text a bit ?
I've been searching in this forum and google and didn't find the answer yet.
Hi, Lan
if yo want to place a line you may choose underline option. Otherwise take a line/draw a line and keep space between the text and line.
Hope this helps
HamidIs there a way easily?
I already know that that solution. But it is troublesome when I face editing later - I have to edit all of it.
But thanks for the answer :) -
Reading a text file line by line and splitting each line into an array
I have a text file that I want to read in line by line and within each line, I want to do some processing. I have a file like the following:
apples||oranges||bananas||grapes
cars||trucks||planes||boats
And I want to end up with an array such that
First...
item(0) = apples
item(1) = oranges
item(2) = bananas
item(3) = grapes
Then move onto the next line with item getting cleared each time. Can anyone offer any ideas on how do to this? I am unclear on reading line by line and then also splitting into an array as I am new to this.
Thanks.For reading a text file in line by line, you want to use a FileReader (java.io.FileReader)
If you wrap it in a Buffered reader, you can call readLine() and get the file one line at a time.
File file = new File("C:\myFile.txt");
BufferedReader in = new BufferedReader(new FileReader(file));
String s = in.readLine();
while (s != null){
// string handling here
s = in.readLine();
}For the second part, you probably want to look at the method String.split() which should split your string up into an array for you. Check out the API for java.lang.String
Check out the -
Extra space in end of line constant
Hello All,
Does anyone have an explanation why when using an end of line constant and a format into string there is an "apparent" extra space included?
The attached VI (LV 8.5) shows the behaviour. There should not be a space after the "e", but there appears to be. If you view the string in hex form there is clearly not an extra space character. What is going on here, am I misinterpreting how this is supposed to work?
nrp
CLA
Attachments:
odd.vi 7 KBHi nrp,
Man I was trigger happy.
I see what you mean, if you step through the 'normal' string you will notice their's a position after the 'e' before going to the next lin.
This was my original reply (humble, humble)
I don't really get what you mean but I think you need to remember the 'hex' view is a formatted view, with an additional space after every second character!
The function returns this for me:
Which is totally acceptable for me. I see 5 characters ('o','n','e','CR','LF')
Ton
Message Edited by TonP on 12-27-2007 04:47 PM
Message Edited by TonP on 12-27-2007 04:49 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be!
Attachments:
odd-1_BD.png 1 KB -
Writing To A Specific Text File Line
In a program I am writing I need to be able to write to the end of a specific line in a textfile. I'm not sure of any particular way to do this apart from perhaps rewriting the whole textfile which would be a pain to do. Does anyone know of a simpler way of how to do this?
RandomAccessFile would help somewhat; with it you could overwrite at a given location by moving the file pointer. The problem with this is it still doesn't solve your case, which is appending. Files are essentially large arrays of data, so you can't easily insert data in the middle of it without having to rewrite the remaining portion of the file.
-
Read data from a text file, one line at a time.
I need to read data from a text file, and display each line in a String Indicator on Front Panel. It displays each line, but I get Error 4, End Of Line, unless I enter an extra line of data in the file that I don't need. I tried Read From Text File.vi, made by Nat Instr, and it gave the same error.
The Read from Text File.vi reads data from a text file line by line until the user stops the VI manually with the Stop button on the front panel, or until an error (such as "Error 4, End of file") occurs. If an error occurs, the Simple Error Handler.vi pops up a dialog that tells you which error occurred.
The Read from Text File.vi uses a while loop, but if you knew how many lines you wanted to read, you could replace the while loop with a for loop set to read that many lines from the file.
If you need something more dynamic because the number of lines in your files vary, then you could change the code of the Read from Text File.vi to the expect "Error 4, End of file" and handle it appropriately. This would require unbundling the error cluster that comes fro
m the Read File function with the Unbundle By Name function, so that you can expose the individual error "status" and error "code" values stored in the cluster. If the value of the error "code" is 4, then you can change the error "status" from true to false, and you can rebundle the cluster with the Bundle by Name function. Setting the error "status" to false instructs the Simple Error Handler to ignore the error. Otherwise, pass the original error cluster to the Simple Error Handler.vi, so that you can see what the error is.
Of course, if you're not interested in what the errors are, you could just remove the Simple Error Handler.vi, but then you wouldn't see any error messages.
Best of Luck,
Dieter
Dieter Schweiss
Applications Engineer
National Instruments
Maybe you are looking for
-
Difficulties using iCal because time isn't showing up.
I am trying to make a schedule for school using ical but on the left hand side in the weekly view it does not display the time of day. Instead it just says sat and then noon and then continues with sat. I tried logging on as a guest and it worked fin
-
F110 - email id for remittance to vendor
Hello Sap Guru, When we execute F110 (automatic payment program), email goes to vendor for payment advice. We need to check from where this automatic email trigger to vendor. How can we check this Thanks & Regards Deepak Garg
-
Hello Experts, We have a requirement where the user fills a form and the details are updated in a table. Now these datials I have to add in the existing PO in EBP ( we are in ECS scenario )as a new line item. All the details are available in the tabl
-
Lightroom 3 forgets catalog location
Lightroom 3 on Snow Leopard forgets where my catalog is every time I restart my computer. LR remembers just fine if I shut LR down and re-open it, but once I re-boot the computer I receive an error message saying it can't find the default catalog an
-
JBuilder vs. J2SDK?
Hello All, I use J2SDK 1.4.0-beta3 (active) on my PC and have 1.3.1 (inactive) in a separate directory. The I/O window is the DOS command window. A board requires that I download something called JBuilder IDE (38MB). The board is a TINI (DS80C390-bas