473,857 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Processing "wide" CSV file

Hi,

I have to process a very "wide" CSV file. Basically, the file does not
appear correctly in Notepad, WordPad etc because each line is 414 characters
wide. Ordinarily, I would have read the file into a StreamReader and
processed each line in turn e.g.

objSR = new StreamReader(st rFileSpec);

while ((strLineIn = objSR.ReadLine( )) != null)
{
// process the line
}

However, in this case, ReadLine() does not return the full 414 characters
which go to make up each line.

What are my options here? Should I use ReadBlock()? Or is a StreamReader not
even the correct object to do this sort of thing?

FYI, the file is downloaded from a legacy VMS mainframe via FTP, and it
appears that this process is inserting arbitrary carriage-returns because of
the line length. Excel also cannot import it correctly because of this,
although SQL Server's DTS can...

Also, if I reformat the file manually so that all the columns "line up", as
it were, I can process it normally with the ReadLine() method. Maybe the
answer is to remove all of the carriage-returns first, insert one every 414
characters and then process the file as normal?

Any assistance gratefully received.

Mark
Nov 17 '05 #1
1 1586
First off, I'd recommend my csv parser,
http://www.geocities.com/shriop/index.html . I'd be interested in
seeing how my parser handles these lines that are causing you issues.
As far as ReadLine is concerned, I can't think of a way that there
could be random carriage returns inserted into the data that would trip
up ReadLine but would not trip up DTS unless the carriage returns that
you're seeing are actually part of the data and are contained in text
qualified fields. Can you post an example line of data from the file so
I can get a better idea of what exactly is going on?

Mark Rae wrote:
Hi,

I have to process a very "wide" CSV file. Basically, the file does not
appear correctly in Notepad, WordPad etc because each line is 414 characters
wide. Ordinarily, I would have read the file into a StreamReader and
processed each line in turn e.g.

objSR = new StreamReader(st rFileSpec);

while ((strLineIn = objSR.ReadLine( )) != null)
{
// process the line
}

However, in this case, ReadLine() does not return the full 414 characters
which go to make up each line.

What are my options here? Should I use ReadBlock()? Or is a StreamReader not
even the correct object to do this sort of thing?

FYI, the file is downloaded from a legacy VMS mainframe via FTP, and it
appears that this process is inserting arbitrary carriage-returns because of
the line length. Excel also cannot import it correctly because of this,
although SQL Server's DTS can...

Also, if I reformat the file manually so that all the columns "line up", as
it were, I can process it normally with the ReadLine() method. Maybe the
answer is to remove all of the carriage-returns first, insert one every 414
characters and then process the file as normal?

Any assistance gratefully received.

Mark


Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1469
by: Posadas, Dennis | last post by:
I don't want to have to compile python, but I need one ready to support unicode that includes CJK. Dennis
3
2653
by: Jonathan Mcdougall | last post by:
I started using boost's filesystem library a couple of days ago. In its FAQ, it states "Wide-character names would provide an illusion of portability where portability does not in fact exist. Behavior would be completely different on operating systems (Windows, for example) that support wide-character names, than on systems which don't (POSIX). Providing functionality that appears to provide portability but in fact
16
2957
by: J. C. Denton | last post by:
I just manually validated alexa's global top 100 sites and find only 2 sites that pass validation. They are http://www.microsoft.com/ http://www.wikipedia.org/ All others should go w3c markup hall of shame, ;-)
2
1352
by: kevininstructor | last post by:
My group is in the process of replacing desktop computers with laptops for several developers for primarily .NET development. What we thought about this morning was the possibility of using an external 19" wide screen monitor. My question: Anyone have experience using a 19" wide screen? Do you like it or would you have preferred a regular 19" monitor? Side note: Although I have not tried this myself I am thinking 1024x768 or
3
10617
by: mr | last post by:
How can i 'force' c++ to interprete "blabla" strings as unicode string instead of ascii string (i just don't want to add 'L' before the thousands strings that are on my projects...), as all my projects are using unicode, and i don't see any reason that c++ compilator keep creating ascii Is it a way? thanks !
1
2244
by: kellygreer1 | last post by:
Is there an easy way from .NET to register a Windows-wide keyboard shortcut? I would like to bring up a WinForm window from an already running .NET application whenever this keyboard shortcut is used. I assume the way to do this is calling the Windows API from .NET. Anyone have an experience with this? or can you point me in the right direction? Thanks in advance, Kelly Greer
3
34177
by: Ioannis Vranos | last post by:
Is printf("%ls") for printing wchar_t strings defined in C90, or it was added in C95?
5
13735
by: workingstiff19 | last post by:
I just want people to click on a link to download a file. I've done it before, but this is a new computer and I must be missing something. (Possibly an Apache configuration setting?) Here is the source for the link that generates the error: <a href="./procedures/ODBC_installation.pdf">ODBC driver installation procedure</a><br /> The permissions on the file and the directory containing it are wide
0
9923
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9768
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10808
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10394
tracyyun
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...
0
9549
agi2029
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...
0
5774
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...
1
4592
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
2
4191
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3215
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.