Python

Pandas Read_Table()

Pandas come with various tools to read the data from links and files, which we can use in our development or research process. We will go through one method: the read_table() and its few examples.

What Is the Read_Table() Method

Pandas is a popular data analysis, exploration, and manipulation tool. We regularly use the URLs and files to do the different activities while researching in real-world data. Pandas provide multiple tools. One of its approaches is the read_table(). It is quite similar to the Pandas read_csv() method. Like the read_csv() method, this also reads the given table, including the DataFrames. In addition, we can also specify various options to get customized rows from the given table.

Examples of Read_Table() Method

Example #1

With columns separated by ‘,’ display the whole file contents.

# importing pandas

import pandas as pd

pd.read_table('file.csv',delimiter=',')

Example #2

Skipping rows without updating the indexes of the rows

# importing pandas

import pandas as pd

pd.read_table('file.csv',delimiter=',',skiprows=5,index_col=0)

Example #3

The following code allows you to skip rows with updated indexes:

# importing pandas

import pandas as pd

pd.read_table('file.csv',delimiter=',',skiprows=5)

Example #4

If you simply wish to read the top few lines, set the nrows option to the appropriate number of lines.

# importing pandas

import pandas as pd

pd.read_table('file.csv',delimiter=',', index_col=0, nrows=5)

Example #5

Set the skipfooter option to the required number from the bottom to skip the lines as shown in the following command:

# importing pandas

import pandas as pd

pd.read_table('file.csv',delimiter=',',index_col=0, engine='python', skipfooter=5)

Conclusion

We discussed the description and examples of the Pandas read_table() method, which reads the tables from files and links. We also learned how we could skip and get customized rows from the given input according to our needs.

About the author

Simran Kaur

Simran works as a technical writer. The graduate in MS Computer Science from the well known CS hub, aka Silicon Valley, is also an editor of the website. She enjoys writing about any tech topic, including programming, algorithms, cloud, data science, and AI. Travelling, sketching, and gardening are the hobbies that interest her.