It is built on top of pd.read_csv() method.
Delimiter for separating data; default is whitespace ('\s+').
import pandas as pd
import pyperclip
# Data to be copied to clipboard
data = """ID\tName\tAge
1\tAlice\t25
2\tBob\t30
3\tCharlie\t35
"""
# Copy the data to the clipboard
pyperclip.copy(data)
# Read the data from the clipboard using pandas
df = pd.read_clipboard(sep='\t')
# Print the DataFrame
print(df)
'''
Output:
ID Name Age
0 1 Alice 25
1 2 Bob 30
2 3 Charlie 35
'''
The dtype_backend parameter is new in Pandas 2.0 which is used to specify the backend for handling the types of data when reading a file.
This parameter allows you to pass additional keyword arguments that are forwarded to the underlying pd.read_csv method.
import pandas as pd
import pyperclip
# Data to be copied to clipboard
data = """IDabcNameabcAge
1abcAliceabc25
2abcBobabc30
3abcCharlieabc35
"""
# Copy the data to the clipboard
pyperclip.copy(data)
# Read the data from the clipboard using pandas
df = pd.read_clipboard(sep='abc', index_col='ID')
# Print the DataFrame
print(df)
'''
Output:
Name Age
ID
1 Alice 25
2 Bob 30
3 Charlie 35
'''