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
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1415
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.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 782
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: Baidu [Spider] and 6 guests