Append lines in a .CSV

This is the place for queries that don't fit in any of the other categories.

Append lines in a .CSV

Postby Khardin » Sun Feb 24, 2013 7:39 am

Hello, I have a .CSV file which contains comments, my problem is that a single comment is separated into several lines with a random number of empty cells between (no more than 20). What I would like to do is append each block of comments into a single line. What I have done so far is replace all empty cells with "null" so that they can be skipped based on containing "null" (no desirable text contains the word null). I am a total python noob and have been trying to do this in excel, but I have a friend who is experienced with python willing to help me run the code if I can figure out what needs to be done. Your help is much appreciated.

An example of what I have is:
Comment 1
null
null
Comment 2(a)
Comment 2(b)
Comment 2(c)
null
Comment 3

What I need to have is
Comment 1
Comment 2(a) comment 2(b) comment 2(c)
Comment 3
Khardin
 
Posts: 1
Joined: Sun Feb 24, 2013 7:27 am

Re: Append lines in a .CSV

Postby metulburr » Sun Feb 24, 2013 8:17 am

Hello, I have a .CSV file which contains comments, my problem is that a single comment is separated into several lines with a random number of empty cells between (no more than 20). What I would like to do is append each block of comments into a single line. What I have done so far is replace all empty cells with "null" so that they can be skipped based on containing "null" (no desirable text contains the word null). I am a total python noob and have been trying to do this in excel, but I have a friend who is experienced with python willing to help me run the code if I can figure out what needs to be done. Your help is much appreciated.

An example of what I have is:
Comment 1
null
null
Comment 2(a)
Comment 2(b)
Comment 2(c)
null
Comment 3

What I need to have is
Comment 1
Comment 2(a) comment 2(b) comment 2(c)
Comment 3


What code do you have so far? And dont forget to read this
we will be moving to python-forum.io on October 1 2016
more details here
User avatar
metulburr
 
Posts: 2243
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Append lines in a .CSV

Postby Yoriz » Sun Feb 24, 2013 10:30 am

As your friend is experienced in python and willing to help you, give them a copy of your csv file and manually do each stage writing down each step of whats required so they can get python to do it for you.
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Yoriz
 
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 12 guests