I am migrating a program from C++ to C# and have encountered a difficulty in
reading the data files. For example, when the data file looks like the
following:
75000 77270
7900 8030
*Note that the spacing between the numbers are tabs, and there is a return
between subsiquent lines.
The C++ code to read this is the following:
ifstream InputFile("ActI nput.inp");
InputFile >> SpadaVol[0] >> SpadaMaxVol;
InputFile >> ChapVol[0] >> ChapMaxVol;
I understand the use of StreamReader to read a line, as there are many posts
and instructions on that topic, but I am unable to find a methodology to read
tab delimited or space seperated files (with a variable or consistent number
of spaces). Most annoyingly, there is a broken link in a post to a csv (and
apparently tab delimited) file reader. 2 2470
Can you be more specific on where the broken link was pointing to? It's
possible that it's to a site of mine, or that I would know what was on
it. Also, I sell a csv parser that would fit the bill, http://www.csvreader.com . My methodology is a complex one based on
speed and a state machine that handles text qualifiers, and escaping
within the data if for instance there's a tab inside one of your cells.
The simple answer to your question is to do ReadLine to read in the
file, and use Split to split based on each occurance of a tab, but like
I said, this method wouldn't handle proper delimited files such as csv.
Ben Enfield wrote: I am migrating a program from C++ to C# and have encountered a difficulty in reading the data files. For example, when the data file looks like the following:
75000 77270 7900 8030
*Note that the spacing between the numbers are tabs, and there is a return between subsiquent lines.
The C++ code to read this is the following:
ifstream InputFile("ActI nput.inp"); InputFile >> SpadaVol[0] >> SpadaMaxVol; InputFile >> ChapVol[0] >> ChapMaxVol;
I understand the use of StreamReader to read a line, as there are many posts and instructions on that topic, but I am unable to find a methodology to read tab delimited or space seperated files (with a variable or consistent number of spaces). Most annoyingly, there is a broken link in a post to a csv (and apparently tab delimited) file reader.
Hi,
Go to www.opennetcf.org they have a free CSV data provider.
I dont remember if they handle the TAB as a field separator though
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ben Enfield" <Ben En*****@discuss ions.microsoft. com> wrote in message
news:20******** *************** ***********@mic rosoft.com... I am migrating a program from C++ to C# and have encountered a difficulty in reading the data files. For example, when the data file looks like the following:
75000 77270 7900 8030
*Note that the spacing between the numbers are tabs, and there is a return between subsiquent lines.
The C++ code to read this is the following:
ifstream InputFile("ActI nput.inp"); InputFile >> SpadaVol[0] >> SpadaMaxVol; InputFile >> ChapVol[0] >> ChapMaxVol;
I understand the use of StreamReader to read a line, as there are many posts and instructions on that topic, but I am unable to find a methodology to read tab delimited or space seperated files (with a variable or consistent number of spaces). Most annoyingly, there is a broken link in a post to a csv (and apparently tab delimited) file reader. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gill Bates |
last post by:
I'm trying to login to a banking site
(https://www.providentconnection.com) using vb.net. I've tried many
variations of WebClient and HttpWebRequest; none of which I've got to
work. My latest version is:
Dim myWebClient As New WebClient
Dim nvc As New NameValueCollection
nvc.Add("Login", username)
nvc.Add("Password", password)
|
by: Howard |
last post by:
Hello
I need some help with this. I want to assign the content of a static
txt/html file to my string a.
<script runat="server" language="C#">
private void Page_Load(object sender, System.EventArgs e)
{
string a =
//include static html page welcome.htm
|
by: Carsten Kraft |
last post by:
Hello Newsgroup,
I think this is easy for you: I want to save the data line by line into an
string array.
eg.
Text file: Array
Line 1 Line1
|
by: Hareth |
last post by:
How do I open a file (such as .txt) in C#.....
I tried:
String File;
File = txtMain.Text;
dlgOpen.ShowDialog();
File = dlgOpen.FileName;
|
by: David |
last post by:
hello... i've a little problem here... n00b question -))
so if you can help me...
the "output" string bellow, comes in UNICODE, but i want to get it on
windows-1251 (cytillic)
how can i do this?..
webResponse = (HttpWebResponse)webRequest.GetResponse();
Stream streamResponse = webResponse.GetResponseStream();
StreamReader streamRead =...
| |
by: Lukasz Lacki |
last post by:
i want to convert string to base64 byte array. i've got problem with
it, class Convert is not very helpfull for me.
how make such converion in simplest way (input = string / output =
byte Base64)
...and.. some more
1) how convert string to byte ?
2) is there a possibility, to make a stream reading from string (like
StringReader, but...
|
by: David Lozzi |
last post by:
Howdy,
I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then
save it back to my SQL server using a SQLCommand, all HTML characters are
changed to HTML code, i.e. >strong< instead of <strong> and so on. Is
this a problem with the editor or something else? Does .Net convert it? I
had to disable page validate request...
|
by: Alex Maghen |
last post by:
I frequently find myself wanting to insert some basic client-side JavaScript
functions in the page of an ASPX of mine. But I find it so frustrating that I
have to actually contruct my JavaScript in C# on the server-side and render
it to the client because I can't use the IDs of my controls as they are
written in the HTML page itself. Rather, I...
|
by: Kevin Blount |
last post by:
As mentioned before, I'm creating a multi-lingual page where the text of
the page comes from a database. This page includes a registration form
which asks for address information, including the Country.
I have 6 .txt files that contain a complete list of countries that we
sell to (65 in total), each written in the appropriate way for the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
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...
|
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...
|
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...
| |