dbf
dbf copied to clipboard
CSV Headers with formatting characters enclosing the column name
I was wondering if there is a way to get rid of the formatting characters that are added to the headers when exporting a database DBF to a CSV?
(b'Name',4) (b'Address',7) and so on...
I assume this extra characters are to apply the bold type for the number of characters that the string contains, or something like that, but since I'm trying to dump those CSV into another database, they are causing me issues. The field name with no extras would be awesome...
Great assets, by the way, it helped me a lot!
This is the code I have, by the way:
import csv, os
import dbf
input_path = r"c:\dbf"
input_extension = ".dbf"
output_path = r"c:\csv"
output_extension = "_link.csv"
for file in os.listdir(input_path):
if file.endswith(".dbf"):
input_file = os.path.join(input_path, file)
output_file = os.path.join(output_path, file[:-4] + output_extension)
print(input_file, "will be converted to", output_file)
with dbf.Table(input_file) as current_file:
current_file1 = os.path.join(output_path, output_file[:-4] + output_extension)
dbf.export(current_file, current_file1.lower())
`
This has been fixed, although I can't recall when. Added a test for it in v0.99.001.
Thanks for bug report, and my apologies for not getting back to you sooner.