473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Double commas in CSV file in C#

132 100+
Hello there.

I am reading in a CSV file and have found that where a field is null (empty) I need to replace this with a value, such as 0.

In an ideal world the following command would work:

stringName.Replace(",,", ",0,");

This does not work but I am wondering if there is a way to replace the double commas in the string with ,0, values?

The input file is very large so editing the file and find/replacing isn't suitable as ultimately this needs to be an automated process with very little intervention, save for browsing to and clicking a load button.

Any help would be very welcome, please.

Thank you.

Mark :o)
Nov 21 '08 #1
2 1862
Plater
7,872 Expert 4TB
Why doesn't that work? Seems like it would, might take a bit, but should work.
If you are producing the file, check to see if the value you are about to write is empty, and if so write a 0?
Nov 21 '08 #2
E11esar
132 100+
Okay I have obviously been working too hard of late as "yes" that has worked..! Not sure why I have had issues with this today but honestly, I've been playing with this for the past hour or so...

Well, it is Friday!!

Thank you for answering :o)
Nov 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brandon McCombs | last post by:
hello, I have an app that pops up a custom dialog box and one of the fields for user input is an account balance field. The data gets put into an Object and eventually into an instance of...
3
by: Jon Maz | last post by:
Hi, A quick one: If you are forming a dynamic sql statement using parameters from a web form, you would normally double up any single inverted commas inputted by the user to stop sql...
4
by: striker | last post by:
I have a comma delimited text file that has multiple instances of multiple commas. Each file will contain approximatley 300 lines. For example: one, two, three,,,,four,five,,,,six one, two,...
1
by: vivekgrs | last post by:
hi i had written text file using vb 6.0 successfully. but i got some problem that i had used the statement for write : Write #2, individual(0); Tab; dd; Tab; dd; Tab; individual(3) ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
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,...
0
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...
0
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,...

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.