Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing data
#4
It may have to do with One Drive - take the file off one drive and store it locally - avoid spaces in your directory naming - If you need a space use - or _ . Or you can try this - let say your directory path is c:\new dir - you could try cd new\dir or cd " new dir ".

I found this code - by googling - copy the code your to editor then save it as win2ubu.py - the rest is explained in the code itself.
This is not my code all credit goes to Joe Dorocak aka Joe Codeswell (JoeCodeswell.com). It may help you to convert your windows directory paths to linux paths.
#!/usr/bin/python
#! python3
#! python2
# -*- coding: utf-8 -*-
"""win2ubu.py changes WINFILEPATH Printing UBUNTU_FILEPATH
Author: Joe Dorocak aka Joe Codeswell (JoeCodeswell.com)
Usage:   win2ubu.py WINFILEPATH
Example: win2ubu.py "C:\\1d\ProgressiveWebAppPjs\\Polymer2.0Pjs\\PolymerRedux\\zetc\\polymer-redux-polymer-2"
    prints /mnt/c/1d/ProgressiveWebAppPjs/Polymer2.0Pjs/PolymerRedux/zetc/polymer-redux-polymer-2
        N.B. spaceless path needs quotes in BASH on Windows   but NOT in Windows DOS prompt!
"""
import sys,os

def winPath2ubuPath(winpath):
    # d,p = os.path.splitdrive(winpath) # NG only works on windows!
    d,p = winpath.split(':')
    ubupath = '/mnt/'+d.lower()+p.replace('\\','/')   
    print (ubupath)
    return ubupath

NUM_ARGS = 1
def main():
    args = sys.argv[1:]
    if len(args) != NUM_ARGS or "-h" in args or "--help" in args:
        print (__doc__)
        sys.exit(2)
    winPath2ubuPath(args[0])

if __name__ == '__main__':
    main()
Reply


Messages In This Thread
Importing data - by Scott - May-10-2018, 08:37 AM
RE: Importing data - by petertyler - May-10-2018, 09:39 AM
RE: Importing data - by Scott - May-11-2018, 03:37 AM
RE: Importing data - by petertyler - May-12-2018, 11:13 AM
RE: Importing data - by snippsat - May-12-2018, 11:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ssues with importing data from ODBC Slavek_d 1 1,444 Feb-01-2022, 09:57 AM
Last Post: ibreeden
  Importing python data to Textfile or CSV yanDvator 0 1,804 Aug-02-2020, 06:58 AM
Last Post: yanDvator
  Importing data from a text file into an SQLite database with Python macieju1974 7 4,267 Jun-29-2020, 08:51 PM
Last Post: buran
  Importing csv data into sql lite cant figure it out. jimmyvegas29 5 3,860 Jul-16-2018, 02:02 AM
Last Post: jimmyvegas29

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020