Hi,
I have a number which is read from the file and the termination of that line is done by "," comma.When I read this number while parsing the file,I get the number as shown below
"1000,"
But I need only "1000" value.How to get rid of the "," from the read number. or is there any way to get rid of the line delimiter while reading the file data.
Could anbody help me in solving this issue
Thanks in advance
PSB
4 1746
Hi,
I have a number which is read from the file and the termination of that line is done by "," comma.When I read this number while parsing the file,I get the number as shown below
"1000,"
But I need only "1000" value.How to get rid of the "," from the read number. or is there any way to get rid of the line delimiter while reading the file data.
Could anbody help me in solving this issue
Thanks in advance
PSB
if the comma is at end of line, just use strip() -
>>> a = "sdfsdf,"
-
>>> a.strip(",")
-
'sdfsdf'
-
>>>
-
pls read the docs.
What about this: -
>>>a = "1000,"
-
>>>print a [:-1]
-
1000
-
-
What about this: -
>>>a = "1000,"
-
>>>print a [:-1]
-
1000
-
-
it can be done but it will strip every last character. it will not work if data is like this
eg
1000,
20000,
3000
40000,
"3000" will become 300
it can be done but it will strip every last character. it will not work if data is like this
eg
1000,
20000,
3000
40000,
"3000" will become 300
I see what you're saying ghostdog74. I was under the impression he wanted a single character removed from the end of a printed line:
1, 25, 78, 345, 672, 1000,
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Shabam |
last post by:
Is there a function in dotnet that allows me to trim user input so that:
1) It gets rid of leading/trailing spaces, tabs, newlines and whatever other
non-printing characters
2) Gets rid of all...
|
by: jose luis fernandez diaz |
last post by:
Hi,
Does any know a algorithm to strip heading and leading blank in a string ?
Tnansk,
Jose Luis
|
by: Simon |
last post by:
Hi,
I have written a function to trim char *, but I have been told that my way
could be dangerous and that I should use memmove(...) instead.
but I am not sure why my code could be 'dangerous'...
|
by: Andy B |
last post by:
I've tried using Trim or RTrim to strip trailing space characters from
my data. When I check on the transformed data space characters are
still there.
We have an address table containing two...
|
by: Durgesh Sharma |
last post by:
Hi All,
Pleas help me .I am a starter as far as C Language is concerned .
How can i Right Trim all the white spaces of a very long (2000 chars)
Charecter string ( from the Right Side ) ? or how...
|
by: Darren Anderson |
last post by:
I have a function that I've tried using in an if then statement and I've
found that no matter how much reworking I do with the code, the expected
result is incorrect.
the code:
If Not...
|
by: Sascha Herpers |
last post by:
Hi,
what is the difference between the trim function and the trim
String-member?
As far as I see it, both return the trimmed string and leave the
original string unaltered.
Is any of the two...
|
by: |
last post by:
I'm just trying to strip non numeric characters out of a string (phone
number) and the following snippet isn't working. It's pretty straight
forward and should working according to:...
|
by: Oleg Subachev |
last post by:
If I apply Trim() method to string consisting of two x0D and x0A characters
the resulting string is not empty but contain the same two charaters: x0D,
x0A.
But according to the help Trim()...
|
by: swengineer001 |
last post by:
Just looking for a few eyes on this code other than my own.
void TrimCString(char *str)
{
// Trim whitespace from beginning:
size_t i = 0;
size_t j;
while(isspace(str))
{
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
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...
| |