Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra new lines from the converted file #2

Open
dpalharini opened this issue Jul 4, 2018 · 1 comment
Open

Remove extra new lines from the converted file #2

dpalharini opened this issue Jul 4, 2018 · 1 comment

Comments

@dpalharini
Copy link

After a file has been converted, a new line is add after every line of content.

This behavior makes annoying the CSV usability without removing the additional lines.

Thank's in advance.

@LukeARG
Copy link

LukeARG commented Jun 7, 2021

Did you find a fix for this? I am having this issue as well
+++++
EDIT 3 hours later, back with a fix. From my research, it looks like an issue dealing with how the DBF file is read, and then how the csv writer saves the file.

I went into the code, and under the __convert function, I added "lineterminator='\n'," to the csv.Dictwriter for output_writer.

Then, when running the code, I had to add -q all argument so that it didn't get messed up

No more double lines for me.

So my output_writer part of the function looks like this now:

  output_writer = csv.DictWriter(output_file,
                                   quoting=args.quoting,
                                   escapechar=args.escape_char,
                                   delimiter=args.delimiter_char,
				   lineterminator='\n',
                                   fieldnames=[encode_decode(x) for x in input_reader.field_names])

Hope this helps someone else out.

References I used:
google.com
https://docs.python.org/3/library/csv.html?highlight=dictwriter#csv.DictWriter
https://stackoverflow.com/questions/3348460/csv-file-written-with-python-has-blank-lines-between-each-row
https://stackoverflow.com/questions/8746908/why-does-csv-file-contain-a-blank-line-in-between-each-data-line-when-outputting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants