有没有办法在 tables.export() 中添加新行

时间:2021-03-16 09:23:38

标签: python python-camelot

所以我做了一个小项目,使用camelot从pdf文件中读取表格(pip install camelot) 我得到了我需要的输出,但它全部排成一行,所以我想知道是否可以从此代码在 json 文件中插入一个新行

import camelot

file = "file.pdf"    

tables = camelot.read_pdf(file, pages='2-end', line_scale=40)

tables.export('files.json', f='json', compress=True) # works for csv, tsv, xsml
[{"0":"Temp.\n\u00b0C","1":"Specific\n Heat\nkJ\/kg K","2":"Density\nkg\/m3","3":"Thermal\n Conductivity\nW\/m K","4":"","5":"Viscosity\nmPa\u2022s","6":"Vapor\n Pressure\nkPa"},{"0":"-40","1":"1.506","2":"990.61","3":"0.1463","4":"","5":"51.05","6":"0.00"},{"0":"0","1":"1.574","2":"953.16","3":"0.1388","4":"","5":"15.33","6":"0.00"},{"0":"40","1":"1.643","2":"917.07","3":"0.1312","4":"","5":"7.00","6":"0.10"},{"0":"80","1":"1.711","2":"881.68","3":"0.1237","4":"","5":"3.86","6":"1.46"},{"0":"120","1":"1.779","2":"846.35","3":"0.1162","4":"","5":"2.36","6":"9.30"},{"0":"160","1":"1.847","2":"810.45","3":"0.1087","4":"","5":"1.54","6":"35.00"},{"0":"200","1":"1.916","2":"773.33","3":"0.1012","4":"","5":"1.05","6":"94.60"},{"0":"240","1":"1.984","2":"734.35","3":"0.0936","4":"","5":"0.74","6":"204.80"},{"0":"280","1":"2.052","2":"692.87","3":"0.0861","4":"","5":"0.54","6":"380.20"},{"0":"320","1":"2.121","2":"648.24","3":"0.0786","4":"","5":"0.41","6":"630.50"},{"0":"360","1":"2.189","2":"599.83","3":"0.0711","4":"","5":"0.31","6":"961.20"},{"0":"400","1":"2.257","2":"547.00","3":"0.0635","4":"","5":"0.25","6":"1373.00"}]

这是我的输出,但我需要更引人注目的输出

0 个答案:

没有答案