Hi All, back in VC++ we had flexibility of reading the line defined by our
own terminator...
get(buf,sizeof( buf),chTerminat or);
Is there something similar in C#... My file is not terminated by new
lines...instead they are terminated by a special character..I want to avoid
doing a read byte by byte to the terminator, instead want to read the whole
line at once...but use the terminator of my choice instead of \n or \r\n
TIA 5 2145
Why not read the whole file as one piece into mem and then split it?
Why not use read to end and then split
ie
StreamReader istream = new StreamReader(fi lename);
string[] lines = istream.ReadToE nd().Split('c') ;
where 'c' is your delimiter, you then have an array of lines, which you can
process.
"Vai2000" wrote: Hi All, back in VC++ we had flexibility of reading the line defined by our own terminator... get(buf,sizeof( buf),chTerminat or);
Is there something similar in C#... My file is not terminated by new lines...instead they are terminated by a special character..I want to avoid doing a read byte by byte to the terminator, instead want to read the whole line at once...but use the terminator of my choice instead of \n or \r\n
TIA
Can't do that FileSize > 250MB
"Joep" <St***@DeStoep. nl> wrote in message
news:41******** *************** @news.xs4all.nl ... Why not read the whole file as one piece into mem and then split it?
Vai2000 <no****@microso ft.com> wrote: Hi All, back in VC++ we had flexibility of reading the line defined by our own terminator... get(buf,sizeof( buf),chTerminat or);
Is there something similar in C#... My file is not terminated by new lines...instead they are terminated by a special character..I want to avoid doing a read byte by byte to the terminator, instead want to read the whole line at once...but use the terminator of my choice instead of \n or \r\n
Don't read a byte at a time, but read chunks at a time, still using
StreamReader, but reading (say) 8192 characters at a time. If you don't
find your delimiter, append it to a StringBuilder. If you do, process
that chunk.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks u all, I guess my question was addressing a different point. I know
how to do the suggestions.
If u guys know the specific answer..please feel free.
TIA
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Vai2000 <no****@microso ft.com> wrote: Hi All, back in VC++ we had flexibility of reading the line defined by
our own terminator... get(buf,sizeof( buf),chTerminat or);
Is there something similar in C#... My file is not terminated by new lines...instead they are terminated by a special character..I want to
avoid doing a read byte by byte to the terminator, instead want to read the
whole line at once...but use the terminator of my choice instead of \n or \r\n
Don't read a byte at a time, but read chunks at a time, still using StreamReader, but reading (say) 8192 characters at a time. If you don't find your delimiter, append it to a StringBuilder. If you do, process that chunk.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Russell E. Owen |
last post by:
At one time, mixing for x in file and readline was dangerous. For
example:
for line in file:
# read some lines from a file, then break
nextline = readline() # bad
would not do what a naive user might expect because the file iterator
buffered data and readline did not read from that buffer. Hence the call
to readline might unexpectedly skip some lines.
|
by: John C. Worsley |
last post by:
I've got an extremely inscrutable problem here using Perl's
Term::ReadLine::Gnu module. I'm using Perl 5.8.0, readline 4.3 and
Term::ReadLine::Gnu 1.14.
The problem is specific to catching INT signals while in the
readline() function. In C, when I've set a SIGINT handler using
signal(), it is immediately called (even in readline()) when I hit
CTRL-C. Likewise in Perl, if I am reading in a while() loop from
STDIN, and I have set the...
|
by: Jian Qiu |
last post by:
Hi, I tried to install python2.4.2. Unfortunately building 'readline'
extension failed.
Here is what I got: (It is a bit long. If you are impatient, please look
at the end where it reports the warning.)
building 'readline' extension
gcc -pthread -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC
-fno-strict-aliasing -I. -I/nfs/gs/home/jianq/Python-2.4.2/./Include
-I/gs/home/jianq/include -I/usr/local/include
|
by: David Bear |
last post by:
I built python 2.4.2 for suse linux 9.3. I configured it to be a separate
instance of python from the version packaged with suse.
Now when I start it I get an error:
python
Python 2.4.2 (#4, Jul 27 2006, 14:34:30)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "/etc/pythonstart", line 7, in ?
|
by: PointMan |
last post by:
what i know is...
while ((currentStr = sr.ReadLine()) != null)
{
in this area,
can i get next ReadLine Value of currentStr
}
best regard,,
| |
by: 7stud |
last post by:
Hi,
1) Does this make any sense:
"""
Thus, the loop:
for line in f:
iterates on each line of the file. Due to buffering issues,
|
by: Sean Davis |
last post by:
I have a large file that I would like to transform and then feed to a
function (psycopg2 copy_from) that expects a file-like object (needs
read and readline methods).
I have a class like so:
class GeneInfo():
def __init__(self):
#urllib.urlretrieve('ftp://ftp.ncbi.nih.gov/gene/DATA/
gene_info.gz',"/tmp/gene_info.gz")
|
by: Akira Kitada |
last post by:
Hi list,
I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed
to build some of the modules.
"""
Failed to find the necessary bits to build these modules:
_bsddb _sqlite3 _tkinter
gdbm linuxaudiodev spwd
sunaudiodev
|
by: Akira Kitada |
last post by:
Hi Marc-Andre,
Thanks for the suggestion.
I opened a ticket for this issue: http://bugs.python.org/issue4204
Now I understand the state of the multiprocessing module,
but it's too bad to see math, mmap and readline modules, that worked
fine before,
cannot be built anymore.
|
by: M.-A. Lemburg |
last post by:
On 2008-10-25 20:19, Akira Kitada wrote:
Thanks.
The errors you are getting appear to be related to either some
missing header files or a missing symbol definition to enable
these - looking at the ticket, you seem to have resolved all
this already :-)
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |