0

I have been working on writing a script to filter down data from a CSV file being dropped in a windows shared server. The problem lies with it stating that it cannot find the file, despite it existing.

I am running this on Linux (Ubuntu) and I have the drive mapped in the system with samba. The complete file path in samba is:

smb://serverip/csv%20files/rlog.csv

In the Windows server, there are is a space between csv and rlog

Originally it was not seeing the location because \r is a special character and I found that adding r before the string makes it literal.

What I have so far as a script is:

import numpy as np
import pandas as pd

PATH = r"\\serverip\csv%20files\rlog.csv"

data_file = pd.read_csv(PATH, sep="|")

print(data_file)

I have tried the PATH variable with r"\\serverip\csv files\rlog.csv", r"\\serverip\csv%20files\rlog.csv" and smb://serverip/csv%20files/rlog.csv, but they both output the same error.

It outputs the error IOError: File "\\serverip\csv%20files\rlog.csv" does not exist despite it being in the directory and existing.

Is there a special way to do this? Because I am at a loss.

AJSKRILLA
  • 39
  • 1
  • 9
  • Unless you mount your smb url as a smb share, you will not be able to read it. See https://stackoverflow.com/questions/30297355/accessing-shared-smb-ubuntu-in-python-scripts – fn. Dec 11 '18 at 17:47
  • I tried mounting it as a url and that did not work, unfortunately. It gave the same error – AJSKRILLA Dec 14 '18 at 15:46

1 Answers1

0

Pandas has an issue working with Samba. After changing the protocol to CIFS, the issue was resolved. I had to make a directory for the local folder so that the file share can be mapped from the file share; it is the only way for it to work.

sudo mkdir /mnt/cifs

sudo mount -t cifs "//serverip/csv files" /mnt/cifs -o username=un,password=pw,domain=COMPUTER

AJSKRILLA
  • 39
  • 1
  • 9