fixed-width

Why is pandas.read_fwf not skipping the blank line as instructed?

二次信任 提交于 2021-02-11 01:55:15
问题 I'm reading a fixed width format (full source file) full of missing data, so pandas.read_fwf comes in handy. There is an empty line after the header, so I'm passing skip_blank_lines=True , but this appears to have no effect, as the first entry is still full of NaN/NaT: import io import pandas s="""USAF WBAN STATION NAME CTRY ST CALL LAT LON ELEV(M) BEGIN END 007018 99999 WXPOD 7018 +00.000 +000.000 +7018.0 20110309 20130730 007026 99999 WXPOD 7026 AF +00.000 +000.000 +7026.0 20120713 20170822

fixed width data into postgres

ⅰ亾dé卋堺 提交于 2021-02-10 08:33:48
问题 Looking for good way to load FIXED-Width data into postgres tables. I do this is sas and python not postgres. I guess there is not a native method. The files are a few GB. The one way I have seen does not work on my file for some reason (possibly memory issues). There you load as one large column and then parse into tables. I can use psycopy2 but because of memory issues would rather not. Any ideas or tools that work. Does pgloader work well or are there native methods? http://www

fixed width data into postgres

爱⌒轻易说出口 提交于 2021-02-10 08:33:32
问题 Looking for good way to load FIXED-Width data into postgres tables. I do this is sas and python not postgres. I guess there is not a native method. The files are a few GB. The one way I have seen does not work on my file for some reason (possibly memory issues). There you load as one large column and then parse into tables. I can use psycopy2 but because of memory issues would rather not. Any ideas or tools that work. Does pgloader work well or are there native methods? http://www

fixed width data into postgres

白昼怎懂夜的黑 提交于 2021-02-10 08:33:17
问题 Looking for good way to load FIXED-Width data into postgres tables. I do this is sas and python not postgres. I guess there is not a native method. The files are a few GB. The one way I have seen does not work on my file for some reason (possibly memory issues). There you load as one large column and then parse into tables. I can use psycopy2 but because of memory issues would rather not. Any ideas or tools that work. Does pgloader work well or are there native methods? http://www

Saving a Pandas dataframe in fixed format with different column widths

佐手、 提交于 2021-02-05 11:29:06
问题 I have a pandas dataframe (df) that looks like this: A B C 0 1 10 1234 1 2 20 0 I want to save this dataframe in a fixed format. The fixed format I have in mind has different column width and is as follows: "one space for column A's value then a comma then four spaces for column B's values and a comma and then five spaces for column C's values" Or symbolically: -,----,----- My dataframe above (df) would look like the following in my desired fixed format: 1, 10, 1234 2, 20, 0 How can I write a

Reading fixed width format data into R with entries exceeding column width

大兔子大兔子 提交于 2020-06-28 08:24:25
问题 I need to use the Annual Building Permits by Metropolitan Area Data distributed by the US Census Bureau, which are downloadable here as fixed width format text files. Here is an excerpt of the file (I've stripped the column names as they aren't in a nice format and can be replaced after reading the file into a date frame): 999 10180 Abilene, TX 306 298 8 0 0 0 184 10420 Akron, OH 909 905 0 4 0 0 999 13980 Blacksburg-Christiansburg-Radford, VA 543 455 0 4 84 3 145 14010 Bloomington, IL 342 214

writing fixed width, space delimited CSV output in Python

允我心安 提交于 2020-01-30 04:40:53
问题 I would like to write a fixed width, space delimited and minimally quoted CSV file using Python's csv writer. An example of the output: item1 item2 "next item1" "next item2" anotheritem1 anotheritem2 If I use writer.writerow( ("{0:15s}".format(item1), "{0:15s}".format(item2)) ) ... then, with the space delimiter, the formatting is broken as either quotes or escapes (depending on the csv.QUOTE_* constant) are added due to the trailing spaces of the items formatting: "item1 " "item2 " "next