-
Notifications
You must be signed in to change notification settings - Fork 1.2k
No conversion on import for cvs #154
Comments
It looks like it is this line drive/upload.go Seem like it should have a Convert flag somewhere. I was not able to trace the google api that it used to do in the api 2.0 |
Ok, looking further. It looks like v3 is using the mime type to determine if it should convert. When i import my file it looks like it has the right mime type. It is still not converting to a spreadsheet. It is still a doc. Imported 1qKpH0y4NdNiFms9huEdeXurhOIHSDtSc7LuXQE3gvXU with mime type: 'application/vnd.google-apps.spreadsheet' |
I'm having the same issue trying to upload .csv files. |
same problem 👎 |
I am having same problem |
I'm beginning to think that this is a google api problem and looked at the code I tried the other call to upload gdrive upload --mime "text/tab-separated-values" myfile.csv it uploaded with, but the file icon was a green box with an X in it. It didn't convert it, but it did let me convert it after i opened it. The importing command from above would make it to a google doc and it would not let me convert it on the google drive. |
Hey @prasmussen, just wanted to ping you directly about this conversion issue in case you might know of an obvious reason for why things are seemingly currently broken? If not, I'd be happy to dive into the code to try to sort things out myself (and submit a pull request, if you're still cool with accepting those)—just hadn't been annoyed by this issue enough to do so myself yet =P Would be great to hear from you either way! p.s. thanks for having made such an awesome open source CLI gdrive tool 👍 |
I am having the same issue. It says imported with mime type spreadsheet, but drive opens it in text editor. |
I got same issue. Do you plan to fix that ? @prasmussen |
I've got a (somewhat lame + gross, but effective) hacky fix that's been working quite well with regard to importing docs (including csvs/tsvs) into gdrive-native formats with no muss and no fuss. If it's the case that the owner of this repo is too busy with other things to bother with issues and/or PRs, feel free to @ mention me here if you'd be interested in the fix. If there's enough interest (and prasmussen remains MIA) I'd be happy to publicize my fork (don't wanna just do that and then seem like I'm competing with this original repo though—if at all avoidable... 😬) |
p.s. @prasmussen my "fix" is really a regression (to an earlier version of the gDrive API)—also, I'm not totally sure how to incorporate it into a PR for the current version of gDrive API... which is why I haven't officially opened a PR for this. Totally open to discussing it here though if you're up for it! |
I only needed to upload files and convert so I wrote a small program which does exactly that, it also can detect existing file with same name and overwrite it. It uses pydrive and very small (31 lines only!) Only takes 2 arguments, parent directory ID value and file path. (you can get the ID value by entering to folder and copying from URL. It is usually some long text like 0B5XXXXY9KddXXXXXXXA2c3ZXXXX. Script was running for a month now daily and it did not ask for re-auth etc. So -> Works For Me TM! <- You may need to update some paths and what not... So I use it like: I only tested it with .tsv files and it converts successfully to google sheets file so when I click on it, I get sheets... #!/usr/bin/python
import sys
import base64
from os import path
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from pydrive.settings import LoadSettingsFile
gauth = GoogleAuth()
gauth.settings = LoadSettingsFile(filename='/usr/local/scripts/gdrive/settings.yaml')
gauth.CommandLineAuth()
drive = GoogleDrive(gauth)
parentId = sys.argv[1]
myFilePath = sys.argv[2]
myFileName = path.basename(sys.argv[2])
file_list = drive.ListFile({'q': '"'+parentId+'" in parents and title="'+myFileName+'" and trashed=false'}).GetList()
# If file is found, update it, otherwise create new file
if len(file_list) == 1:
myFile = file_list[0]
else:
myFile = drive.CreateFile({"parents": [{"kind": "drive#fileLink", "id": parentId}]})
myFile.SetContentFile(myFilePath)
myFile['title'] = myFileName
myFile.Upload({'convert': True}) settings.yaml client_config_backend: settings
client_config:
client_id: INSERT YOUR CLIENT_ID HERE
client_secret: INSERT YOUR SECRET HERE
auth_uri: https://accounts.google.com/o/oauth2/auth
token_uri: https://accounts.google.com/o/oauth2/token
redirect_uri: urn:ietf:wg:oauth:2.0:oob
revoke_uri:
save_credentials: True
save_credentials_backend: file
save_credentials_file: /usr/local/scripts/gdrive/credentials.json
get_refresh_token: True
oauth_scope:
- https://www.googleapis.com/auth/drive.file |
@yurtesen I am the maintainer of PyDrive - would you mind me adding this script to the examples published in the repository? |
@RNabel thanks for asking. I am surprised that you even found it here :) I don't mind at all. It probably would be worthwhile to convert setting file path to a variable in the script. This was a real quick hack so I didn't bother making it pretty. I would appreciate it if you could just add a line showing that it came from me :) Perhaps something like, if it is ok for you.
|
@yurtesen Just pushed your sample to PyDrive's dev branch, feel free to comment on the commit! |
This seems to be an issue still. The response mentions the right MIME-type ( |
Someone, can you see my patch? 4540c5c I guess a lack option of |
Hi @tomofumi-nakano, I am trying your solution (PR #224), but it doesn't work for me, it is possible that I am doing something wrong. I want to upload a local .csv as a Google Sheet.
I hope the result is a Google Sheet like this: Am I doing something wrong? Thanks! |
Sorry, I forgot about a command option. i.e. ./gdrive import --parent 0B_ulNgvK6XduaUcz3UaaeGRSdWc4 --mime text/csv /tmp/nami20170222.csv |
Thanks for your answer @tomofumi-nakano, but I continue with the same issue using |
same issue... the file is imported like a doc. |
@carrodher This program use local packages and use
It mean this program imports and use the original repository (prasmussen's) code, even if we modify local code. That is why. We need change the import source package name if we use forked repositories. |
Hi Tomofumi-nakano, carrodher, I have the same requirement and I need to copy the CSV to google drive as a google spreadsheet. I am following the same steps I hope this will access your forked code branch and downloaded the code. and I am getting the below error, Failed to upload file: googleapi: Error 400: Bad Request, badRequest I thought it could be authentication and I tried grdive list and its working perfect. Upload is also working. Any idea? Could you please help? Thanks a bunch in advance. Regards |
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com> Signed-off-by: DroidFreak32 <rushabshah32@gmail.com>
[harsh: Fix formatting] Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
When I do
./gdrive import myfile.cvs
it is not converting to a spreadsheet. It imports it as a doc
version 2.1.0 running on ubuntu 14.
By the way great tool!
The text was updated successfully, but these errors were encountered: