| | |
File input method returning blank lines
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 31
Reputation:
Solved Threads: 0
As far as I can tell, this method is returning a blank line every other line, but I can't figure out why:
Does anyone have an idea? I'm sure it's something simple I'm overlooking
.
C# Syntax (Toggle Plain Text)
public static List<string> plain(string path, int num) { List<string> result = new List<string>(); StreamReader reader = File.OpenText(path); string line; int i = 0; while ((line = reader.ReadLine()) != null) { result.Add(line); i++; if (i == num) { break; } } return result; }
Does anyone have an idea? I'm sure it's something simple I'm overlooking
. Last edited by tdeck; Jul 17th, 2009 at 2:07 pm.
Yeah .. it also works fine here.
P.S. Are you sure, that your file, which lays in
)?
P.S. Are you sure, that your file, which lays in
path has text in it (maybe this is that simple, that you're overlooking
)? So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
•
•
Join Date: Jul 2009
Posts: 31
Reputation:
Solved Threads: 0
Hmm... I think it's the input file I used. It's generated from a python script, and I think the script replaced the \n with \r\n. So, since I'm sending \r\n, it puts \r\r\n in the file. Which, oddly, shows up as just one line break in notepad and textpad
.
In case you're curious:
http://www.python-forum.org/pythonfo...=13807&start=0
-Weird
.In case you're curious:
http://www.python-forum.org/pythonfo...=13807&start=0
-Weird
In that case you might want to use this:
That should fix it :-)
c# Syntax (Toggle Plain Text)
line.Replace("\\r\\r\\n", "");
That should fix it :-)
Live free.... Die Hard!
![]() |
Similar Threads
- Skipping blank lines (Python)
- How to delete blank lines in a file?? (Python)
- File and RE as the Input... (Computer Science)
- Batch Insert Lines to an INI file problem : BLANK LINES? (Legacy and Other Languages)
- Scanner Blank Lines (JavaScript / DHTML / AJAX)
- Server file input? (Java)
- Client side code for a Web Method Returning a complex Custom data type. (RSS, Web Services and SOAP)
- Storing file input to an array? (C)
- get rid of blank lines with strreplace() (PHP)
Other Threads in the C# Forum
- Previous Thread: Using List and Random
- Next Thread: windows control library
Views: 498 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C#
.net 2d access algorithm application array asp.net bitmap box button c# check checkbox class code color combo combobox connectionproblem control conversion csharp custom data database datagrid datagridview dataset degrees directshow display dll drawing event excel expression file form format forms ftp function game gcd gdi+ graphics image index input internet label list listbox listener login math mysql notepad object operator photoshop picturebox print programming recursion remote remoting resource resourcefile round saving search server socket sql sql-server start statistics stream string text textbox thread threading time timer treeview tutorial update validation vc++ video view visual webbrowser webcam windows winforms wpf xml





