Skip to content Skip to sidebar Skip to footer

Python - Parsing A Text Onto Columns By The Position Of Each Item

The Bovespa (brazilian stock exchange) offer a file with all the quotes in a timeframe. The file is too large, and each line are something like this real sample: So, looking for t

Solution 1:

You have a fixed width format: this will do the trick.

pd.read_fwf(file_path, widths=[...],names=[...])

you should pass the list of widths, which in your case starts as [2,8,2,10,...] and the list of columns ['register','date','code','ticker',...]

Post a Comment for "Python - Parsing A Text Onto Columns By The Position Of Each Item"