carolinux / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
0 stars 1 forks source link

InsertRow, UpdateCell, etc. fails in spreadsheetExample.py #363

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download the latest gdata-python-client
2. Create a spreadsheet on Google Docs, add some columns
3. Run spreadsheetExample.py
4. Select the spreadsheet created recently
5. Select cells and then enter a simple command, like "update 2 A Blah"

What is the expected output? What do you see instead?
I would expect it to update the cell in the document's worksheet, but 
instead it fails with the following error:

Command: update 2 A blah
Traceback (most recent call last):
  File "spreadsheetExample.py", line 199, in <module>
    main()
  File "spreadsheetExample.py", line 195, in main
    sample.Run()
  File "spreadsheetExample.py", line 166, in Run
    self._PromptForCellsAction()
  File "spreadsheetExample.py", line 74, in _PromptForCellsAction
    self._CellsUpdateAction(parsed[0], parsed[1], parsed[2])
  File "spreadsheetExample.py", line 107, in _CellsUpdateAction
    key=self.curr_key, wksht_id=self.curr_wksht_id)
  File "/usr/local/lib/python2.6/dist-
packages/gdata/spreadsheet/service.py", line 270, in UpdateCell
    entry = self.GetCellsFeed(key, wksht_id, cell)
  File "/usr/local/lib/python2.6/dist-
packages/gdata/spreadsheet/service.py", line 215, in GetCellsFeed
    converter=gdata.spreadsheet.SpreadsheetsCellFromString)
  File "/usr/local/lib/python2.6/dist-packages/gdata/service.py", line 
1103, in Get
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid query 
parameter value for R2CA.', 'reason': 'Bad Request'}

What version of the product are you using?
2.0.9, also encountered with 1.2.4 (Ubuntu package)
Python 2.6.5
Ubuntu 10.04

Please provide any additional information below.
I get a similar error for InsertRow:

Command: insert Date=blah
Traceback (most recent call last):
  File "spreadsheetExample.py", line 199, in <module>
    main()
  File "spreadsheetExample.py", line 195, in main
    sample.Run()
  File "spreadsheetExample.py", line 169, in Run
    self._PromptForListAction()
  File "spreadsheetExample.py", line 91, in _PromptForListAction
    self._ListInsertAction(command[1])
  File "spreadsheetExample.py", line 118, in _ListInsertAction
    self.curr_key, self.curr_wksht_id)
  File "/usr/local/lib/python2.6/dist-
packages/gdata/spreadsheet/service.py", line 336, in InsertRow
    converter=gdata.spreadsheet.SpreadsheetsListFromString)
  File "/usr/local/lib/python2.6/dist-packages/gdata/service.py", line 
1231, in Post
    media_source=media_source, converter=converter)
  File "/usr/local/lib/python2.6/dist-packages/gdata/service.py", line 
1352, in PostOrPut
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'We&#39;re sorry, a 
server error occurred. Please wait a bit and try again.', 'reason': 'Bad 
Request'}

Original issue reported on code.google.com by thelu...@gmail.com on 7 May 2010 at 5:04

GoogleCodeExporter commented 9 years ago
Oops, I should have been using the command "update 2 1 Blah" in the first 
example. 
That works for me. But InsertRow still fails.

Original comment by thelu...@gmail.com on 7 May 2010 at 5:22

GoogleCodeExporter commented 9 years ago
OK, I have found a workaround for this issue. Sorry for the confusion...

The column names can't have an uppercase character in them when doing an 
InsertRow or 
using other row commands. If the spreadsheet has uppercase column names, they 
must be 
referred to in lowercase for Row commands to work. This is not documented 
anywhere I 
can see...

Original comment by thelu...@gmail.com on 7 May 2010 at 5:35

GoogleCodeExporter commented 9 years ago
Wow.  Who would have thunk it.  That fixed my problem with InsertRow also.  
Weird.  Nice work to root out the problem.  Thanks.

Original comment by ryan.ke...@gmail.com on 10 Aug 2010 at 12:08

GoogleCodeExporter commented 9 years ago
thank you thelusiv! i lost the day trying to figure this out

Original comment by eduardo....@gmail.com on 29 Aug 2010 at 12:58

GoogleCodeExporter commented 9 years ago
Fixed in revision 915 by adding a note to the sample program output about not 
using uppercase column names.

Original comment by vicfry...@google.com on 20 Dec 2010 at 2:47

GoogleCodeExporter commented 9 years ago
guys... I just encountered the same issue... and 1) the link to the revision 
915, is broken... 2) as a solution is pretty lame... anyway, I'm reproducing 
the same issue, and I have lowercase column names (or u meant the content as 
well? cause that is the case for me)

Original comment by guido.se...@gmail.com on 13 Apr 2011 at 10:58

GoogleCodeExporter commented 9 years ago
this is the row I'm inserting...

{'value': '1.2986', 'trade': 'EURCHF=X'}

and this is the error...

Traceback (most recent call last):
  File "./g_write", line 23, in <module>
    status = not main(sys.argv)
  File "./g_write", line 19, in main
    excel.write(data)
  File "/Users/zeph/tmp/berliner/berliner/gdatalib.py", line 55, in write
    entry = self.gd_client.InsertRow(trow, self.curr_key, curr_wksht_id)
  File "/Users/zeph/tmp/berliner/gdata/spreadsheet/service.py", line 336, in InsertRow
    converter=gdata.spreadsheet.SpreadsheetsListFromString)
  File "/Users/zeph/tmp/berliner/gdata/service.py", line 1236, in Post
    media_source=media_source, converter=converter)
  File "/Users/zeph/tmp/berliner/gdata/service.py", line 1358, in PostOrPut
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'We're sorry, a server 
error occurred. Please wait a bit and try reloading your spreadsheet.', 
'reason': 'Bad Request'}

Original comment by guido.se...@gmail.com on 13 Apr 2011 at 11:01

GoogleCodeExporter commented 9 years ago
sorry, seems to be this... 
http://code.google.com/p/gdata-python-client/issues/detail?id=481

Original comment by guido.se...@gmail.com on 14 Apr 2011 at 8:44

GoogleCodeExporter commented 9 years ago
Agreed that the fix in this case is absolutely lame. Any explanation as to why 
the headers can't have upper case letters? Why not fix the library to convert 
to lower case automatically?

Original comment by ells.da...@gmail.com on 6 Jul 2011 at 9:43

GoogleCodeExporter commented 9 years ago
Sorry, meant to add this diff for file src/gdata/spreadsheet/service.py. Is 
there any reason this is not a reasonable solution?

--- service.py  2011-07-06 16:49:07.000000000 -0500
+++ service.py.new  2011-07-06 16:48:57.000000000 -0500
@@ -326,7 +326,7 @@
     new_entry = gdata.spreadsheet.SpreadsheetsList()
     for k, v in row_data.iteritems():
       new_custom = gdata.spreadsheet.Custom()
-      new_custom.column = k
+      new_custom.column = k.lower()
       new_custom.text = v
       new_entry.custom[new_custom.column] = new_custom
     # Generate the post URL for the worksheet which will receive the new entry.

Original comment by ells.da...@gmail.com on 6 Jul 2011 at 9:48

GoogleCodeExporter commented 9 years ago
I agree with you, it sucks that header values cannot have uppercase characters. 
 This is something we'll fix in a new version of the API, but not in this one.  
Sorry.

Thanks,
Vic

Original comment by vicfry...@google.com on 10 Jul 2011 at 4:45

GoogleCodeExporter commented 9 years ago
hi guys... sorry, but this doesn't seem to fix it... my column names are 
already lower case... "value, trade", I anyway applied your patch but... 
yeah... here u go

dyn-136-wlan-client:berliner zeph$ ./y_fetch |./g_write 
('EURUSD=X', '1.4146')
('EURCHF=X', '1.1533')
('EURGBP=X', '0.8763')
 - username: xxxx
 - password: 
{'value': '1.1533', 'trade': 'EURCHF=X'}
Traceback (most recent call last):
  File "./g_write", line 23, in <module>
    status = not main(sys.argv)
  File "./g_write", line 19, in main
    excel.write(data)
  File "/Users/zeph/tmp/github.com/berliner/berliner/gdatalib.py", line 58, in write
    entry = self.gd_client.InsertRow(trow, self.curr_key, curr_wksht_id)
  File "/Users/zeph/tmp/github.com/berliner/gdata/spreadsheet/service.py", line 339, in InsertRow
    converter=gdata.spreadsheet.SpreadsheetsListFromString)
  File "/Users/zeph/tmp/github.com/berliner/gdata/service.py", line 1236, in Post
    media_source=media_source, converter=converter)
  File "/Users/zeph/tmp/github.com/berliner/gdata/service.py", line 1358, in PostOrPut
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'We're sorry, a server 
error occurred. Please wait a bit and try reloading your spreadsheet.', 
'reason': 'Bad Request'}

Original comment by guido.se...@gmail.com on 15 Jul 2011 at 3:35

GoogleCodeExporter commented 9 years ago
Wow.  Lifesaver....

Original comment by jong...@google.com on 16 Jul 2011 at 11:11

GoogleCodeExporter commented 9 years ago
Thank you online community!!!!!!!!!

Original comment by philhwag...@gmail.com on 17 Aug 2011 at 11:39

GoogleCodeExporter commented 9 years ago
this is still a problem in gdata 2.0.14 regardless of lowercase or not.

Command: update 1 A blah
Traceback (most recent call last):
  File "spreadsheetExample.py", line 200, in <module>
    main()
  File "spreadsheetExample.py", line 196, in main
    sample.Run()
  File "spreadsheetExample.py", line 167, in Run
    self._PromptForCellsAction()
  File "spreadsheetExample.py", line 74, in _PromptForCellsAction
    self._CellsUpdateAction(parsed[0], parsed[1], parsed[2])
  File "spreadsheetExample.py", line 108, in _CellsUpdateAction
    key=self.curr_key, wksht_id=self.curr_wksht_id)
  File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/gdata/spreadsheet/service.py", line 270, in UpdateCell
    entry = self.GetCellsFeed(key, wksht_id, cell)
  File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/gdata/spreadsheet/service.py", line 215, in GetCellsFeed
    converter=gdata.spreadsheet.SpreadsheetsCellFromString)
  File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/gdata/service.py", line 1108, in Get
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid query parameter 
value for R1CA.', 'reason': 'Bad Request'}

Original comment by garlan...@gmail.com on 1 Sep 2011 at 9:05

GoogleCodeExporter commented 9 years ago
I agree.  There is still a problem.  umm, can someone fix this please? 

gdata-2.0.15/samples/spreadsheets$

cells or list? cells
dump
update {row} {col} {input_value}
Command: update 1 a 00
Traceback (most recent call last):
  File "spreadsheetExample.py", line 202, in <module>
    main()
  File "spreadsheetExample.py", line 198, in main
    sample.Run()
  File "spreadsheetExample.py", line 169, in Run
    self._PromptForCellsAction()
  File "spreadsheetExample.py", line 74, in _PromptForCellsAction
    self._CellsUpdateAction(parsed[0], parsed[1], parsed[2])
  File "spreadsheetExample.py", line 109, in _CellsUpdateAction
    key=self.curr_key, wksht_id=self.curr_wksht_id)
  File "/usr/local/lib/python2.7/dist-packages/gdata/spreadsheet/service.py", line 273, in UpdateCell
    entry = self.GetCellsFeed(key, wksht_id, cell)
  File "/usr/local/lib/python2.7/dist-packages/gdata/spreadsheet/service.py", line 218, in GetCellsFeed
    converter=gdata.spreadsheet.SpreadsheetsCellFromString)
  File "/usr/local/lib/python2.7/dist-packages/gdata/service.py", line 1108, in Get
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid query parameter 
value for R1Ca.', 'reason': 'Bad Request'}

Thanks

Chris

Original comment by chrismru...@gmail.com on 26 Nov 2011 at 10:00

GoogleCodeExporter commented 9 years ago
Still a issue with 2.0.16

Traceback (most recent call last):
  File "C:\tools\ides\eclipse\indigo32bit\plugins\org.python.pydev.debug_2.4.0.2012020116\pysrc\pydevd.py", line 1307, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\tools\ides\eclipse\indigo32bit\plugins\org.python.pydev.debug_2.4.0.2012020116\pysrc\pydevd.py", line 1060, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "C:\Users\Alex\workspaces\pythonWS\PythonProj1\src\run_nightlies.py", line 546, in <module>
    main()
  File "C:\Users\Alex\workspaces\pythonWS\PythonProj1\src\run_nightlies.py", line 87, in main
    do_nightlies();
  File "C:\Users\Alex\workspaces\pythonWS\PythonProj1\src\run_nightlies.py", line 171, in do_nightlies
    add_new_failures_to_spreasheet(newFailures);
  File "C:\Users\Alex\workspaces\pythonWS\PythonProj1\src\run_nightlies.py", line 542, in add_new_failures_to_spreasheet
    entry = gd_client.InsertRow(fixedFailures[0], spreadSheetKey, workSheetKey)
  File "C:\Python27\lib\site-packages\gdata\spreadsheet\service.py", line 339, in InsertRow
    converter=gdata.spreadsheet.SpreadsheetsListFromString)
  File "C:\Python27\lib\site-packages\gdata\service.py", line 1236, in Post
    media_source=media_source, converter=converter)
  File "C:\Python27\lib\site-packages\gdata\service.py", line 1358, in PostOrPut
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Attribute name "Suite" 
associated with an element type "ns1:Test" must be followed by the ' = ' 
character.', 'reason': 'Bad Request'}

Original comment by bre...@gmail.com on 5 Feb 2012 at 9:24

GoogleCodeExporter commented 9 years ago
Another choke point occurs if original column headers contain underscores.  
Remove any underscores from column headers and retry.

Original comment by mdbree...@gmail.com on 27 Nov 2012 at 8:54

GoogleCodeExporter commented 9 years ago
I also have this bad request problem with InsertRow, with a dict as simple as:

asd = {'a':'Kervin', 'b':'Ang', 'c':'29', 'd': '9/12/1977', 'e':'asdasd'}

This is the only workaround I've found: 
http://code.google.com/p/gdata-python-client/issues/detail?id=481#c13

Original comment by eduardos...@gmail.com on 18 Dec 2012 at 11:24