1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-b63d84ab8fc7> in <module>
3 #result = [(0, 4), (4, 14), (14, 18), (18, 20), (20, 28), (28, 36), (36, 38), (38, 46), (46, 52), (52, 60), (60, 68), (68, 80), (80, 100), (100, 116), (116, 132), (132, 142), (142, 152), (152, 156), (156, 181), (181, 182), (182, 187), (187, 207), (207, 211), (211, 212), (212, 222), (222, 234), (234, 254), (254, 274), (274, 275), (275, 283), (283, 291), (291, 299), (299, 311), (311, 313), (313, 373), (373, 379), (379, 419), (419, 451), (451, 455), (455, 465), (465, 473), (473, 483), (483, 501), (501, 505), (505, 515), (515, 518), (518, 526), (526, 534), (534, 539), (539, 555), (555, 557), (557, 559), (559, 561), (561, 562), (562, 566), (566, 568), (568, 571), (571, 586), (586, 601), (601, 616), (616, 631), (631, 681), (681, 697), (697, 709), (709, 713), (713, 723), (723, 731), (731, 732), (732, 740), (740, 741), (741, 756), (756, 771), (771, 777), (777, 782), (782, 783), (783, 798), (798, 813), (813, 828), (828, 843), (843, 858), (858, 873), (873, 874), (874, 882), (882, 892), (892, 893), (893, 894), (894, 909), (909, 910), (910, 913), (913, 923), (923, 943), (943, 947), (947, 962), (962, 977), (977, 992), (992, 995), (995, 1003), (1003, 1011), (1011, 1024), (1024, 1044), (1044, 1060), (1060, 1074), (1074, 1090), (1090, 1100), (1100, 1110), (1110, 1111), (1111, 1115), (1115, 1117), (1117, 1127), (1127, 1137), (1137, 1161), (1161, 1167), (1167, 1169), (1169, 1182), (1182, 1183)]
4
----> 5 pd.read_fwf('FI.TXT', colspecs=result, header=None)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in read_fwf(filepath_or_buffer, colspecs, widths, infer_nrows, **kwds)
780 kwds["infer_nrows"] = infer_nrows
781 kwds["engine"] = "python-fwf"
--> 782 return _read(filepath_or_buffer, kwds)
783
784
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
446
447 # Create the parser.
--> 448 parser = TextFileReader(fp_or_buf, **kwds)
449
450 if chunksize or iterator:
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds)
878 self.options["has_index_names"] = kwds["has_index_names"]
879
--> 880 self._make_engine(self.engine)
881
882 def close(self):
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine)
1124 '"python-fwf")'
1125 )
-> 1126 self._engine = klass(self.f, **self.options)
1127
1128 def _failover_to_python(self):
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, f, **kwds)
3659 self.colspecs = kwds.pop("colspecs")
3660 self.infer_nrows = kwds.pop("infer_nrows")
-> 3661 PythonParser.__init__(self, f, **kwds)
3662
3663 def _make_reader(self, f):
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, f, **kwds)
2273 # Set self.data to something that can read lines.
2274 if hasattr(f, "readline"):
-> 2275 self._make_reader(f)
2276 else:
2277 self.data = f
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in _make_reader(self, f)
3662
3663 def _make_reader(self, f):
-> 3664 self.data = FixedWidthReader(
3665 f,
3666 self.colspecs,
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, f, colspecs, delimiter, comment, skiprows, infer_nrows)
3573 and isinstance(colspec[1], (int, np.integer, type(None)))
3574 ):
-> 3575 raise TypeError(
3576 "Each column specification must be "
3577 "2 element tuple or list of integers"
TypeError: Each column specification must be 2 element tuple or list of integers |
Partager