I have table.csv with plant varieties linked with SNP Markers(400). One marker is occuring in 20 varities. I would like to make a separate csv file for each marker which should have variety and other columns. I am new in python and trying to use Pandas. I wrote the following:
import os
from io import open
import pandas as pd
dfs = pd.read_csv('/home/System/Variety_Marker.csv', sep='\t', encoding='latin-1', low_memory=False)
for i in dfs.groupby('MARKER'):
tables = i
df = pd.DataFrame(i) # tuple change into dataframe
df.to_csv(f"/home/System/table_{i}.csv")
OSError: [Errno 36] File name too long:
The commands are taking the values , headers and all information as naming csv file.I am thankful in advance. Please help to resolve this issue..
Try to print the results of
f"/home/System/table_{i}.csv"
and see filename its trying to write to.Why is this tagged with
R
?If I can get solution in R too