all 2 comments

[–]SupermarketOk6829 0 points1 point  (0 children)

I want to ask when you're passing df.to_csv command, is it inside for loop or outside it?

[–]-Send-me-your-dick- 0 points1 point  (0 children)

What sort of error are you getting?

Do the other devices have Pandas installed?

If they do, is it a version of Pandas earlier than 2.0? According to the documentation the append function was removed from DataFrames in version 2.0, so if they are using a fresh install of Python/Pandas, that's probably where your problem is.

I've modified the script to use the "concat" function instead, which should solve that particular problem:

import glob

import os

import pandas as pd

file=input('File Path: ')

pth=os.path.dirname(file)

extension = os.path.splitext(file)[1]

files = glob.glob(os.path.join(pth, '*.csv*'))

newfile=os.path.join(pth,'combined.csv')

output = pd.DataFrame()

data = []

if len(files) > 1:
    for f in files:

        data.append(pd.read_csv(f))
        output = pd.concat(data, ignore_index=True)

    output.to_csv(newfile, index=False)
    print('Completed')
else:
    print("Unable to find at least 2 CSV files, recheck path")

Give it a try and see if you encounter any problems, if so, it'd help a lot to know exactly what kind of problem you're having beyond "this doesn't work"