I am trying to write some data into a csv file, but when I write the file the data skips a line. I tried putting commas at the end of the write line but that did not work.
Attached is the part of the code where I write the data. - writer.writerow(datim + [button1]+ [row['cruise']] + [row['crunum']]+ [sitecode]+ [SeriesCode]+ [deploynum]+ [DeploymentCode]+ [ctd]+ [blat] + [blon]+[deploymenteklog]+ [Deploymentcom1 + str(deploynum)]),
-
-
writer.writerow(datim + [button2]+ [row['cruise']] + [row['crunum']]+[sitecode]+[SeriesCode]+[deploynum]+[DeploymentCode]+[ctd]+[elat]+[elon]+[deploymenteklog]+[Deploymentcom2 + str(deploynum)]),
-
Thanks
3 1946 bvdet 2,851
Expert Mod 2GB
There's not much to go on, because I have no idea what the variables are assigned to. My guess is that one of the values has a trailing newline character. The newline character can be removed with str method strip().
Since you are using the csv module and the default line termination sequence is '\r\n', that's why you get a new line. You can try following way and it should work for you. - writer.writerow(yourrow, lineterminator = '\r')
You can also use strip(), and avoid the possibility that some lines contain a newline and some do not. - str_out = ""
-
for field in [datim, button1, row['cruise'], row['crunum'], sitecode, SeriesCode, deploynum, DeploymentCode, ctd, blat, blon, deploymenteklog, Deploymentcom1, str(deploynum)]:
-
str_out += field.strip()
And then write str_out configured however you wish.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JC |
last post by:
I am using Mysql version: 4.0.18-max-log
and trying to populate a database from a text file using source option from
inside the mysql environment.
The population run OK but when creating the...
|
by: CJ |
last post by:
I've got following:
> file_a content needs to be compared with file_b content.
I want to write content in binary form, then run a line by line
comparison on characters. When the first different...
|
by: sunphan |
last post by:
Hello all
I wanted to create a data file from a stored procedure in DB2. I have to select few millions records, do certain checking or calculation on fields, store/append it in file and this will...
|
by: brabster |
last post by:
Hi, this is my first post so please excuse any mistakes!
I'd like to write files using an upload script in my website, but I'm having problems. I don't seem to be able to write a file. Ive set up...
|
by: pablo.erba |
last post by:
Hi Everyone, I´m new to this group, I´m trying to write a text files
adding content from a text column (more than 8000 characters), I found
code how to write files and it works but i have the...
|
by: William Manley |
last post by:
According to what I read in the ConfigParser module, this should work, but it doesn't. Can anyone point out what I'm doing wrong?
def writeinifile ( self, FILE='P:/INI/test.ini',...
|
by: Debabrata Jana |
last post by:
Hi all,
I use solaris 5.8 OS.
I have three OS user :
1) orac9ias
2)oracle9i
3)backup
I use the following command to export a oracle export backup (I use oracle9i release 1):
|
by: FingerDemon |
last post by:
I'm guessing I'm missing something obvious here, but I have searched around and re-read my Python books and references on simple file writing and I can't see the answer. I am running this in Windows...
|
by: Mr fahad |
last post by:
#include <stdio.h>
#include <conio.h>
void main (void)
{
char ch;
FILE *fp;
fp=fopen ("fahd.txt","w");
while (ch=fgetc( )!='\r')
fputc (ch,fp);
fclose (fp);
|
by: Jim |
last post by:
Hi There,
I'm trying to read a file character by character. When I write the
file out, there is one extra character which shows on the screen as a
solid circle with a small question mark in the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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...
| |