Latest Uploads
Extraterre ... .0.1 (zip)

dantheman363

Monty Teas ... Screenie 1

steve_ancell

Santa Clau ... ed his bag

waroffice

manic_platdude.png

spinal

Tetris Clone

steve_ancell

Super blues bros.

spinal

Forum Home

Discussion point: read one long line or multiple short lines?

UserMessage
Posted : Friday, 23 May 2008, 10:38 | Permalink | Mark Here
Forklift_Fred


WW Entries : 9
This is a question that doesn't really need an answer as the implementation I'm looking for is minimal and decided on by other factors, but I wondered what everyone thought of the matter...

It's also one that can be tested and so on, but I can't be bothered

I'm writing a very simple little application for work, like one I've mentioned before. I basically need to read in less than 20 pieces of text (stored in a TXT or CSV so it can be easily edited at a later date) and shove them into a collection of Types.

My question then...

Is it quicker to read one line from a file then parse it with comma separations or have each string on one line and read 20 lines from the file?

I'm thinking, for ease of editing, I'll save it as a CSV and read multiple lines. That way it can be sorted and entries can be deleted quickly and easily in Excel (which is in common use by the manager who is likely to edit it)

I'd started with a single line because I'd just been working with comma separation and I thought one read would be quicker but it's getting messy with different string lengths:

-->

My algorithm isn't quite right anyway so I have to re-code.

So... a lot of waffle for a simple question! What are your thoughts?

Discuss...

-----
Come rain or shine...
Posted : Friday, 23 May 2008, 11:01 | Permalink | Mark Here
Andy_A


Reading the entire line of text from a disk file into a single string is definitely going to be faster. Then just parse the line for the different fields and store the values in an array for sorting/searching.

This might do what you want

http://socoder.net/index.php?snippet=13836
Posted : Friday, 23 May 2008, 11:24 | Permalink | Mark Here
JL235


WW Entries : 7
If you can guarantee the structure, then I'd read one line at a time. I also wouldn't worry about performance until after it's done.

But personally I would do neither. I'd just read and read turning the input into tokens. Some example tokens: WHITESPACE, TEXT, COMMA, END_OF_LINE and NUMBER. The idea being that what you do next is based on the tokens you've just received. Some like TEXT and NUMBER would also store their number and text inside. This token idea is how a lot of parsers work.

-----
PlayMyCode.com - build and play in your browser, Blog, Twitter.
Posted : Friday, 23 May 2008, 11:26 | Permalink | Mark Here
Forklift_Fred


WW Entries : 9
What Andy said is basically what I'm doing and it's all over in a matter of seconds anyway. It probably takes longer to open up the executable than it takes to run the code but it saves a couple of minutes from doing it manually

The idea is to read in a much larger CSV report (Currently about 600 lines - 54kb!) and ignore any lines that contain my listed entries. So ultimately, there's going to be about 600 ReadLine anyway a few WriteLine (in theory it would be zero but the point of the report is to find the problems and the examples I'm working with end up with about 25 lines)

I'm now wondering whether the 600 line report could be read as a single chunk of data and then converted and checked (or just checked as raw data???

-----
Come rain or shine...
Posted : Saturday, 24 May 2008, 15:45 | Permalink | Mark Here
Afr0


WW Entries : 3
there's going to be about 600 ReadLine anyway


Please don't say you're going to hardcode 600 string variables into your program - right?

-----
Afr0 Games

Project Dollhouse on Github - Please fork!
Posted : Saturday, 24 May 2008, 17:47 | Permalink | Mark Here
Forklift_Fred


WW Entries : 9
No!

Only the 20 or so in my list get stored, the 600 are read, processed and forgotten. Nothing's hardcoded anyway, that's the whole point.

-----
Come rain or shine...
Posted : Sunday, 25 May 2008, 08:14 | Permalink | Mark Here
Afr0


WW Entries : 3
Ah, good.
As for reading a single chunk of data... that should be entirely possible!
Just create a memorybank (or databank, or whatever it's called in Blitz), and poke it all in to there. Then you peek in a loop and use string commands to check it.

-----
Afr0 Games

Project Dollhouse on Github - Please fork!
Latest Posts
Coder's Block
Jayenkai Thu 09:01
Consumer Lockout
9572AD Thu 06:09
Professor Oak, Honest!!
spinal Wed 23:24
Position in Mind
steve_ancell Wed 20:11
Sonic Adventure v0.x
Jayenkai Wed 07:08
FIRST!!!
steve_ancell Wed 03:55
Noel's Graduation
waroffice Wed 02:55
Monkey vs iOS tweaks
spinal Tue 22:51
Fucking Pound Sign Unicode Bullshit Bollocks
Dabz Tue 13:00
Progress / Location Bars
dna Tue 08:55
More

Latest Items
News : Newsletter #176
Jayenkai Sat 04:49
News : Newsletter #175
Dabz Tue 09:38
Blog : Snow: More Material Junk
Cower Sat 23:17
Dev-Diary : Mutant Monty: Amstrad CPC to Windows conversion
rockford Fri 13:14
Techy : AppleTV
Jayenkai Thu 09:40
Blog : Graphviz
steve_ancell Sat 14:17
Pets : Top-Down Shadow Hack
Jayenkai Tue 05:52
Snippet : JNKrunch v1.0
Jayenkai Sat 07:20
News : Newsletter #173
waroffice Fri 04:47
Blog : Material Loading
Cower Fri 02:08
Pets : I Done Won A Thing
shroom_monk Sun 11:31
Pets : Repurposing A Lexer
Cower Mon 22:06
Bah : Feeling a Little Angry
spinal Mon 11:26
News : Newsletter #170
Dabz Sat 00:34
Showcase : sbfgen
Cower Sat 16:57
More

Who's Online
HoboBen
Fri, at 17:07
Evil Roy Ferguson
Fri, at 17:04
steve_ancell
Fri, at 17:03
Jayenkai
Fri, at 16:48
CodersRule
Fri, at 16:21
shroom_monk
Fri, at 16:06
dna
Fri, at 15:04
spinal
Fri, at 14:30
Dabz
Fri, at 13:41
Cower
Fri, at 13:39
Link to this page
Site : Jayenkai 2006-Infinity |
MudChat's origins, BBCode's former life, Image Scaler.