使用Python将.csv文件转换为.dbf? [英] Convert .csv file into .dbf using Python?

查看:1280
本文介绍了使用Python将.csv文件转换为.dbf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用python脚本将.csv文件转换为.dbf文件?我在网上找到此一块的代码,但我不确定它是多么可靠。是否有任何模块有这个功能?

解决方案

你不会在网上找到任何东西读取CSV文件并写入DBF文件,以便您可以调用它并提供2个文件路径。对于每个DBF字段,您需要指定类型,大小和(如果相关)小数位数。



一些问题:



什么软件将使用输出DBF文件?



没有类似the(一个也是唯一)DBF文件格式的东西。你需要dBase III吗? dBase 4? 7? Visual FoxPro?等等?



您需要写入的文本字段的最大长度是多少?



如果您的要求是最小的(dBase) III格式,没有非ASCII文本,文本<= 254字节长,Python 2.X),那么你引用的食谱应该做的工作。


How can I convert a .csv file into .dbf file using a python script? I found this piece of code online but I'm not certain how reliable it is. Are there any modules out there that have this functionality?

解决方案

You won't find anything on the net that reads a CSV file and writes a DBF file such that you can just invoke it and supply 2 file-paths. For each DBF field you need to specify the type, size, and (if relevant) number of decimal places.

Some questions:

What software is going to consume the output DBF file?

There is no such thing as "the" (one and only) DBF file format. Do you need dBase III ? dBase 4? 7? Visual FoxPro? etc?

What is the maximum length of text field that you need to write? Do you have non-ASCII text?

Which version of Python?

If your requirements are minimal (dBase III format, no non-ASCII text, text <= 254 bytes long, Python 2.X), then the cookbook recipe that you quoted should do the job.

这篇关于使用Python将.csv文件转换为.dbf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆