Load data from txt with pandas

file-io, pandas, python

Solution

You can do as:

import pandas as pd
df = pd.read_csv('file_location\filename.txt', delimiter = "\t")

(like, df = pd.read_csv('F:\Desktop\ds\text.txt', delimiter = "\t")

Problem

I am loading a txt file containig a mix of float and string data. I want to store them in an array where I can access each element. Now I am just doing ``` import pandas as pd data = pd.read_csv('output_list.txt', header = None) print data ``` Each line in the input file looks like the following: ``` 1 0 2000.0 70.2836942112 1347.28369421 /file_address.txt ``` Now the data are imported as a unique column. How can I divide it, so to store different elements separately (so I can call `data[i,j]`)? And how can I define a header?

Original source

Related problems