Re: JSON encoding PDF or Excel files in Python 2.7

2017-07-21 Thread Skip Montanaro
> JSON supports floats, ints, (Unicode) strings, lists and dicts (with string > keys). It doesn't support bytestrings (raw bytes). Thanks, MRAB and Irmen. It looks like bson does what I need. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: JSON encoding PDF or Excel files in Python 2.7

2017-07-21 Thread MRAB
On 2017-07-21 19:52, Skip Montanaro wrote: I would like to JSON encode some PDF and Excel files. I can read the content: pdf = open("somefile.pdf", "rb").read() but now what? json.dumps() insists on treating it as a string to be interpreted as utf-8, and bytes == str in Python 2.x. I can't jso

Re: JSON encoding PDF or Excel files in Python 2.7

2017-07-21 Thread Irmen de Jong
On 21/07/2017 20:52, Skip Montanaro wrote: > I would like to JSON encode some PDF and Excel files. I can read the content: > > pdf = open("somefile.pdf", "rb").read() > > but now what? json.dumps() insists on treating it as a string to be > interpreted as utf-8, and bytes == str in Python 2.x. I

Re: json to access using python

2017-06-18 Thread mm0fmf
On 18/06/2017 20:34, breamore...@gmail.com wrote: On Sunday, June 18, 2017 at 7:50:10 PM UTC+1, Xristos Xristoou wrote: hello I have a json url and i want from this url to update my table in microsoft access,how to do that using python or some tool of microsoft access ? You need to do some

Re: json to access using python

2017-06-18 Thread breamoreboy
On Sunday, June 18, 2017 at 7:50:10 PM UTC+1, Xristos Xristoou wrote: > hello > > > I have a json url and i want from this url to update my table in microsoft > access,how to do that using python or some tool of microsoft access ? You need to do some research first. Then you run an editor and

Re: JSON confusion

2016-08-17 Thread Terry Reedy
On 8/17/2016 12:35 PM, Steve Simmons wrote: I'm trying to write a small utility to find the closest railway station to a given (UK) postcode but the result is in JSON and I'm not familiar with it. I've got as far as extracting the JSON object and I can print the first level elements ("success" an

Re: JSON confusion

2016-08-17 Thread Steve Simmons
On 17/08/2016 17:49, Jon Ribbens wrote: On 2016-08-17, Steve Simmons wrote: I'm trying to write a small utility to find the closest railway station to a given (UK) postcode but the result is in JSON and I'm not familiar with it. I've got as far as extracting the JSON object and I can print th

Re: JSON confusion

2016-08-17 Thread Jon Ribbens
On 2016-08-17, Steve Simmons wrote: > I'm trying to write a small utility to find the closest railway station > to a given (UK) postcode but the result is in JSON and I'm not familiar > with it. I've got as far as extracting the JSON object and I can print > the first level elements ("success"

Re: JSON result parsing

2016-07-30 Thread Ben Bacarisse
TUA writes: > Calls to my REST api may either return a dict (for single results) or > a list of dicts (for multiple results). I think John's answer missed this part. > I receive these results using the requests library. > > I want to retrieve the value for a key 'ID' but only if I have a > sing

Re: JSON result parsing

2016-07-29 Thread John Gordon
In TUA writes: > I want to retrieve the value for a key 'ID' but only if I have a single > result and, obviously, if ID is present. > How can I do this with pythonic elegance? > Thanks for all suggestions! if len(results) == 1 and 'ID' in results: return results['ID'] else:

Re: JSON to Pandas data frame

2016-06-25 Thread hasan . diwan
David Shi writes: >How to convert a JSON object into a Pandas data frame? You can use read_json -- http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_json.html to read it into a dataframe. Or you can read the json into python objects and use read_records to create a pandas DataFra

Re: JSON Object to CSV file

2015-08-19 Thread ryguy7272
On Wednesday, June 17, 2015 at 11:00:24 AM UTC-4, kbtyo wrote: > I would like to have this JSON object written out to a CSV file so that the > keys are header fields (for each of the columns) and the values are values > that are associated with each header field. Is there a best practice for > w

Re: JSON Object to CSV Question

2015-08-19 Thread ryguy7272
On Thursday, June 18, 2015 at 2:59:11 AM UTC-4, kbtyo wrote: > Good Evening Everyone: > > > I would like to have this JSON object written out to a CSV file so that the > keys are header fields (for each of the columns) and the values are values > that are associated with each header field. Is t

Re: JSON Object to CSV File Troubleshooting

2015-06-23 Thread Sahlusar
On Tuesday, June 23, 2015 at 2:35:50 AM UTC-4, Denis McMahon wrote: > On Sun, 21 Jun 2015 16:56:27 -0700, Sahlusar wrote: > > > Here is an example XML document that I am working with: > > > You are welcome to contribute and provide me with feedback. Thank you > > for your continued feedback and g

Re: JSON Object to CSV File Troubleshooting

2015-06-22 Thread Denis McMahon
On Sun, 21 Jun 2015 16:56:27 -0700, Sahlusar wrote: > Here is an example XML document that I am working with: > You are welcome to contribute and provide me with feedback. Thank you > for your continued feedback and guidance. Your XML is invalid! You have a closing MO tag with no opening tag. >

Re: JSON Object to CSV File Troubleshooting

2015-06-22 Thread Chris Angelico
On Mon, Jun 22, 2015 at 9:33 AM, Denis McMahon wrote: > This is the sort of data conversion code I generally turn out in a day or > so, it's hardly rocket science as long as you have a clear description of > what is required. If you don't have a clear description of what is > required, you have to

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Sahlusar
On Sunday, June 21, 2015 at 7:34:47 PM UTC-4, Denis McMahon wrote: > On Mon, 22 Jun 2015 00:55:11 +0300, Joonas Liik wrote: > > > In xml for instance this is valid: > > > > > 1 > > > > .. and so is this: > > > > 1 2 > > > > What the OP needs to do is sit down with the XML and work out how

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Sahlusar
On Sunday, June 21, 2015 at 5:56:00 PM UTC-4, Waffle wrote: > On 21 June 2015 at 17:38, Sahlusar wrote: > > > > [snip] > > I do agree with you Denis that this is an unconventional approach. I was > > wondering then that perhaps I should add additional functionality at the > > XML to JSON step? S

Re: JSON Object to CSV file

2015-06-21 Thread Sahlusar
On Sunday, June 21, 2015 at 4:54:27 PM UTC-4, Denis McMahon wrote: > On Sun, 21 Jun 2015 06:57:01 -0700, sahluwalia wrote: > > > On Sunday, 21 June 2015 02:47:31 UTC-4, Denis McMahon wrote: > >> On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote: > >> > >> > I would like to have this JSON object

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Denis McMahon
On Mon, 22 Jun 2015 00:55:11 +0300, Joonas Liik wrote: > In xml for instance this is valid: > > 1 > > .. and so is this: > > 1 2 > What the OP needs to do is sit down with the XML and work out how it needs to be represented in CSV terms, and then code that transformation, but it appears

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Joonas Liik
On 21 June 2015 at 17:38, Sahlusar wrote: > > [snip] > I do agree with you Denis that this is an unconventional approach. I was > wondering then that perhaps I should add additional functionality at the XML > to JSON step? So far, with JSON objects without nested lists (as values) I > have been

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Denis McMahon
On Sun, 21 Jun 2015 07:38:13 -0700, Sahlusar wrote: > It is difficult to explain this to someone asynchronously and without an > in person meeting. Moreover, the strict guidelines for disclosing > information make it difficult for me to explain the client's > requirements and the problems that the

Re: JSON Object to CSV file

2015-06-21 Thread Denis McMahon
On Sun, 21 Jun 2015 06:57:01 -0700, sahluwalia wrote: > On Sunday, 21 June 2015 02:47:31 UTC-4, Denis McMahon wrote: >> On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote: >> >> > I would like to have this JSON object written out to a CSV file so >> > that the keys are header fields (for each of

Re: JSON Object to CSV file

2015-06-21 Thread Sahlusar
On Sunday, 21 June 2015 11:31:44 UTC-4, Ned Batchelder wrote: > On Sunday, June 21, 2015 at 10:54:44 AM UTC-4, Sahlusar wrote: > > > This is a duplicate to the post titled: JSON to CSV Troubleshooting: > > Please don't do that. > > --Ned. My apologies - is it possible to delete one of my posts

Re: JSON Object to CSV file

2015-06-21 Thread Ned Batchelder
On Sunday, June 21, 2015 at 10:54:44 AM UTC-4, Sahlusar wrote: > This is a duplicate to the post titled: JSON to CSV Troubleshooting: Please don't do that. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: JSON Object to CSV file

2015-06-21 Thread Sahlusar
On Sunday, June 21, 2015 at 2:47:31 AM UTC-4, Denis McMahon wrote: > On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote: > > > I would like to have this JSON object written out to a CSV file so that > > the keys are header fields (for each of the columns) and the values are > > values that are asso

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Sahlusar
It is difficult to explain this to someone asynchronously and without an in person meeting. Moreover, the strict guidelines for disclosing information make it difficult for me to explain the client's requirements and the problems that they face. I do agree with you Denis that this is an uncon

Re: JSON Object to CSV file

2015-06-21 Thread Sahlusar
On Sunday, June 21, 2015 at 2:47:31 AM UTC-4, Denis McMahon wrote: > On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote: > > > I would like to have this JSON object written out to a CSV file so that > > the keys are header fields (for each of the columns) and the values are > > values that are asso

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Sahlusar
On Sunday, 21 June 2015 02:54:48 UTC-4, Denis McMahon wrote: > On Thu, 18 Jun 2015 18:47:30 -0700, Sahlusar wrote: > > > I have a conundrum regarding JSON objects and converting them to CSV: > > I think your conundrum is that you've taken on a coding task beyond your > abilities to comprehend,

Re: JSON Object to CSV file

2015-06-21 Thread sahluwalia
On Sunday, 21 June 2015 02:47:31 UTC-4, Denis McMahon wrote: > On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote: > > > I would like to have this JSON object written out to a CSV file so that > > the keys are header fields (for each of the columns) and the values are > > values that are associate

Re: JSON Object to CSV File Troubleshooting

2015-06-20 Thread Denis McMahon
On Thu, 18 Jun 2015 18:47:30 -0700, Sahlusar wrote: > I have a conundrum regarding JSON objects and converting them to CSV: I think your conundrum is that you've taken on a coding task beyond your abilities to comprehend, and as a result not only can you not code it, you can't even adequately d

Re: JSON Object to CSV File Troubleshooting

2015-06-20 Thread Denis McMahon
On Thu, 18 Jun 2015 18:47:30 -0700, Sahlusar wrote: > I have a conundrum regarding JSON objects and converting them to CSV: > > Context > > I am converting XML files to a JSON object (please see snippet below) > and then finally producing a CSV file. Here is a an example JSON object: This is wh

Re: JSON Object to CSV file

2015-06-20 Thread Denis McMahon
On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote: > I would like to have this JSON object written out to a CSV file so that > the keys are header fields (for each of the columns) and the values are > values that are associated with each header field. > { > "CF": { ... > "CF": "Fee", Your js

Re: JSON Object to CSV Question

2015-06-20 Thread Saran Ahluwalia
Here is the dictionary that corresponds with the CSV printed to the console: 1. { 2. "PAC": { 3. "Account": [{ 4. "PC": "0", 5. "CMC": "0", 6. "WC": "0", 7. "DLA": "0", 8. "CN": null, 9. "FC": { 10. "Int32": ["0", 11. "0", 12. "0", 13. "0", 14. "0"] 15

Re: JSON Object to CSV Question

2015-06-20 Thread Ned Batchelder
On Saturday, June 20, 2015 at 2:10:51 AM UTC-4, Sahlusar wrote: > @Joonas: > > > The previous example was a typo. Please use the below example as a case > study.  > > > > > {'D_B': ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], 'F_Int32': > ['0', '0', '0', '0', '0', '0', '0'

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
My answers are below in red. On Fri, Jun 19, 2015 at 2:47 PM, Joonas Liik wrote: > > You say you are taking this from an xml file and want to get a CSV file.. > > Why are you making an intermediate JSON file? > I thought that this would be the most efficient method as it emulates Python diction

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
@Joonas: The previous example was a typo. Please use the below example as a case study. 1. {'D_B': ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], 2. 'F_Int32': ['0', 3. '0', 4. '0', 5. '0', 6. '0', 7. '0', 8. '0', 9. '0', 10. '0', 11. '0', 12. '0',

Re: JSON Object to CSV Question

2015-06-19 Thread Joonas Liik
this.. might not throw an eror, but you have 2 keys with the same name "F", and 1 of them will probably be disgarded..., you have data corruption even before you try to process it. { "F": "False", "F": { "Int32": ["0", "0", "0"] }, } you mentioned Excel at one point. perhaps you could mock up w

Re: JSON Object to CSV Question

2015-06-19 Thread Joonas Liik
You say you are taking this from an xml file and want to get a CSV file.. Why are you making an intermediate JSON file? Why do you need the CSV output? Could you perhaps be better off using another format? Your data seems to be a quite deeply nested hierarchical structure and doesn't seem to su

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
Hi Steven, Okay, I understand now how convoluted this sounds. Here is a more focused issue (I hope) referencing the following sample JSON object within a file: 1. "PAC": { 2. "Account": [{ 3. "PC": "0", 4. "CMC": "0", 5. "WC": "0", 6. "DLA": "0", 7. "CN": null, 8. "FC": {

Re: JSON Object to CSV Question

2015-06-19 Thread Steven D'Aprano
On Fri, 19 Jun 2015 07:50 pm, Saran Ahluwalia wrote: > If you read the most recent thread that I just posted it states far more > information The problem is, you are posting *too much* of the *wrong* information. The exception you are getting appears to be a simple one: you are getting the excep

Re: JSON Object to CSV Question

2015-06-19 Thread Sahlusar
On Friday, June 19, 2015 at 8:47:25 AM UTC-4, Sahlusar wrote: > On Friday, June 19, 2015 at 6:16:40 AM UTC-4, Cecil Westerhof wrote: > > Top posting is frowned upon. Could you put your reply under where you > > reply on next time? > > > > On Friday 19 Jun 2015 11:50 CEST, Saran Ahluwalia wrote: >

Re: JSON Object to CSV Question

2015-06-19 Thread Sahlusar
On Friday, June 19, 2015 at 6:16:40 AM UTC-4, Cecil Westerhof wrote: > Top posting is frowned upon. Could you put your reply under where you > reply on next time? > > On Friday 19 Jun 2015 11:50 CEST, Saran Ahluwalia wrote: > > > No I am not a troll. I am attempting to clarify an evolving problem

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
Thank you for clarifying. I will be more cognizant to follow this protocol. Sent from my iPhone > On Jun 19, 2015, at 6:07 AM, Cecil Westerhof wrote: > > Top posting is frowned upon. Could you put your reply under where you > reply on next time? > >> On Friday 19 Jun 2015 11:50 CEST, Saran Ah

Re: JSON Object to CSV Question

2015-06-19 Thread Cecil Westerhof
Top posting is frowned upon. Could you put your reply under where you reply on next time? On Friday 19 Jun 2015 11:50 CEST, Saran Ahluwalia wrote: > No I am not a troll. I am attempting to clarify an evolving problem. > If you read the most recent thread that I just posted it states far > more in

Re: JSON Object to CSV Question

2015-06-19 Thread Saran Ahluwalia
Steve, No I am not a troll. I am attempting to clarify an evolving problem. If you read the most recent thread that I just posted it states far more information - in my humble opinion. Peter was of great assistance. The data becomes more convoluted; as a fairly new programmer I am looking for

Re: JSON Object to CSV File Troubleshooting

2015-06-18 Thread Steve Hayes
On Thu, 18 Jun 2015 18:47:30 -0700 (PDT), Sahlusar wrote: >Good Evening, > >I have a conundrum regarding JSON objects and converting them to CSV: That's the THIRD time you've asked this, in three separate threads. Why don't you read the answers you were given the first time? [follow-ups set]

Re: JSON Object to CSV Question

2015-06-18 Thread Steve Hayes
On Wed, 17 Jun 2015 17:49:35 -0400, Saran Ahluwalia wrote: >Good Evening Everyone: > >I would like to have this JSON object written out to a CSV file so that the You've already said that in another thread, and got several answers. What are you? Some kind of troll? -- Steve Hayes from Tshwane,

Re: JSON Object to CSV Question

2015-06-18 Thread Peter Otten
Saran Ahluwalia wrote: > Good Evening Everyone: > > I would like to have this JSON object written out to a CSV file so that > the keys are header fields (for each of the columns) and the values are > values that are associated with each header field. Is there a best > practice for working with th

Re: JSON Object to CSV file

2015-06-18 Thread Sahlusar
On Wednesday, June 17, 2015 at 2:21:05 PM UTC-4, Peter Otten wrote: > Sahlusar wrote: > > > On Wednesday, June 17, 2015 at 11:00:24 AM UTC-4, Saran A wrote: > >> I would like to have this JSON object written out to a CSV file so that > >> the keys are header fields (for each of the columns) and th

Re: JSON Object to CSV file

2015-06-17 Thread Peter Otten
Sahlusar wrote: > On Wednesday, June 17, 2015 at 11:00:24 AM UTC-4, Saran A wrote: >> I would like to have this JSON object written out to a CSV file so that >> the keys are header fields (for each of the columns) and the values are >> values that are associated with each header field. Is there a

Re: JSON Object to CSV file

2015-06-17 Thread Sahlusar
On Wednesday, June 17, 2015 at 11:00:24 AM UTC-4, Saran A wrote: > I would like to have this JSON object written out to a CSV file so that the > keys are header fields (for each of the columns) and the values are values > that are associated with each header field. Is there a best practice for >

Re: Json Comaprision

2015-05-26 Thread pra devOPS
Hey all thanks for the answers, I am done wiht the same . Sorry fore delayed replied On Wed, May 6, 2015 at 9:27 AM, John Gordon wrote: > In pra devOPS < > siv.dev...@gmail.com> writes: > > > I wanted to compare two json files ignoring few of the keys in the json > > files. > > > Can anybody

Re: Json Comaprision

2015-05-08 Thread Denis McMahon
On Tue, 05 May 2015 12:55:20 -0700, pra devOPS wrote: > I wanted to compare two json files ignoring few of the keys in the json > files. > > Can anybody suggest me few things? json files usually get imported to either a list or a dictionary (unless they're a simple string or number). If the fi

Re: Json Comaprision

2015-05-06 Thread John Gordon
In pra devOPS writes: > I wanted to compare two json files ignoring few of the keys in the json > files. > Can anybody suggest me few things? Load each json file into a python object, delete the keys you don't care about, and compare the two objects. -- John Gordon Imagine what it m

Re: Json Comaprision

2015-05-06 Thread Mark Lawrence
On 05/05/2015 20:55, pra devOPS wrote: Hi All: I wanted to compare two json files ignoring few of the keys in the json files. Can anybody suggest me few things? Thanks, Siva https://docs.python.org/3/library/json.html#module-json -- My fellow Pythonistas, ask not what our language can do

Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
Excellent, thank you. http://bugs.python.org/issue14573 -alfred -- https://mail.python.org/mailman/listinfo/python-list

Re: JSON-encoding very long iterators

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 4:05 PM, Alfred Morgan wrote: > On Wednesday, October 1, 2014 3:55:19 PM UTC-7, Chris Angelico wrote: >> At some point, you'll have to port your patch to the latest codebase > > Okay, done. > > https://github.com/Zectbumo/cpython/compare/master > > Iterators for JSON is now

Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
On Wednesday, October 1, 2014 3:55:19 PM UTC-7, Chris Angelico wrote: > At some point, you'll have to port your patch to the latest codebase Okay, done. https://github.com/Zectbumo/cpython/compare/master Iterators for JSON is now Python 3 ready. -- https://mail.python.org/mailman/listinfo/pytho

Re: JSON-encoding very long iterators

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 8:01 AM, Alfred Morgan wrote: > On Wednesday, October 1, 2014 6:07:23 AM UTC-7, Chris Angelico wrote: >> On Wed, Oct 1, 2014 at 8:13 PM, Alfred Morgan wrote: >> > What do you think now? >> >> I think that you're adding features to Python 2.7, which isn't getting >> new featu

Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
On Wednesday, October 1, 2014 6:07:23 AM UTC-7, Chris Angelico wrote: > On Wed, Oct 1, 2014 at 8:13 PM, Alfred Morgan wrote: > > What do you think now? > > I think that you're adding features to Python 2.7, which isn't getting > new features. That won't be merged into trunk. Does your patch apply

Re: JSON-encoding very long iterators

2014-10-01 Thread Chris Angelico
On Wed, Oct 1, 2014 at 8:13 PM, Alfred Morgan wrote: > I added a stream flag (off by default) and also added file streaming (thanks > for the idea). > > https://github.com/Zectbumo/cpython/compare/2.7 > > What do you think now? I think that you're adding features to Python 2.7, which isn't getti

Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
On Monday, September 29, 2014 7:10:18 PM UTC-7, Ian wrote: > This would cause things that aren't lists to be encoded as lists. > Sometimes that may be desirable, but in general if e.g. a file object > sneaks its way into your JSON encode call, it is more likely correct > to raise an error than to s

Re: JSON-encoding very long iterators

2014-09-29 Thread Ian Kelly
On Mon, Sep 29, 2014 at 7:19 PM, wrote: > I would like to add the ability to JSONEncode large iterators. Right now > there is no way to do this without modifying the code. > > The JSONEncoder.default() doc string suggests to do this: > For example, to support arbitrary iterators, you cou

Re: JSON translated into SQL by python

2013-11-23 Thread Peter Otten
Aaron G. wrote: > I am new to programming python for JSON to SQL and I was wondering why > this does not work. All the values for entering the DB are correct. The > EnterpriseValue data is not entering the database. > #collect data from JSON source at Yahoo > url = ["db", "http://y.ahoo.it/wlB89"

Re: JSON translated into SQL by python

2013-11-23 Thread Jussi Piitulainen
Aaron G. writes: > I am new to programming python for JSON to SQL and I was wondering > why this does not work. All the values for entering the DB are > correct. The EnterpriseValue data is not entering the database. > > #collect data from JSON source at Yahoo > url = ["db", "http://y.ahoo.it/wl

Re: JSON translated into SQL by python

2013-11-22 Thread Chris Angelico
On Sat, Nov 23, 2013 at 4:54 PM, Aaron G. wrote: > query = "INSERT INTO TABLE temp2 (enterprise) VALUES("+ str(curObservation) > +");" You just put the contents of curObservation into the query, as SQL code. Is that really what you wanted to do? Most likely, you should be using a parameterized q

Re: JSON logging ?

2012-12-12 Thread Bart Thate
Ha ! spoke too soon. Was reading this: http://docs.python.org/2/howto/logging-cookbook.htm which explains it all ;] Place to be is the LogRecordStreamHandler ;] Something to play with, first trying out to get a communication channel running o

Re: JSON logging ?

2012-12-12 Thread Bart Thate
Thanks for your reply Chris, good to be updated on the pickle stuff, too bad it is still not safe for use. But hee i prefer JSON above pickle anyways so ;] As to using the logging package to send JSON dict over, the logging stuff should be able to be converted to handle that. Just 2 things that n

Re: JSON logging ?

2012-12-12 Thread Chris Rebert
On Dec 11, 2012 7:33 AM, "Bart Thate" wrote: > pickle uses eval still ? or is is considered safe now ? i was told not to use eval() stuff on data. I don't believe pickle uses eval() per se, but per the red warning box in its docs, it's still not safe when given untrusted input. IIRC, among other

Re: json: python 2.5: error in browser

2011-09-03 Thread Chris Rebert
On Sat, Sep 3, 2011 at 1:58 AM, Vineet Deodhar wrote: > Opera Dragonfly shows this error:-- > > Uncaught exception: SyntaxError: JSON.parse: Unable to parse value: A,B,C > Error thrown at line 3, column 0 in http://127.0.0.1:8000/mywheels/test/cat: >     var ctg = JSON.parse(["A", "B", "C"]); > ~~

Re: json in python 2.5

2011-09-02 Thread Chris Rebert
On Fri, Sep 2, 2011 at 10:36 PM, Vineet Deodhar wrote: >> e.g., I have this list: >> L = ['spam', 'ham', 'eggs', 12, (13.63)] >> What is the correct way to convert L to javascript array format? > Python likewise has a JSON module in the std lib: > http://docs.python.org/library/json.html > ==

Re: JSON Strict Mode

2011-08-05 Thread Chris Rebert
> On Fri, Aug 5, 2011 at 2:19 AM, Chris Rebert wrote: >> On Thu, Aug 4, 2011 at 8:25 PM, John Riselvato >> wrote: >> > I am working on a license verification script. I am rather new to the >> > concept and to JSON files in general. >> > This is what my pseudocode looks like: >> >> >> >> licenses

Re: JSON Strict Mode

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 8:25 PM, John Riselvato wrote: > I am working on a license verification script. I am rather new to the > concept and to JSON files in general. Based on your questions, reading a programming tutorial might be a good idea. Here's one that uses Python and that I've heard prais

Re: json decode issue

2011-07-14 Thread Nobody
On Thu, 14 Jul 2011 10:22:44 -0700, Miki Tebeka wrote: > I'm trying to decode JSON output of a Java program (jackson) and having > some issues. The cause of the problem is the following snippet: > { > "description": "... lives\uMOVE™ OFFERS ", > } > Which causes ValueError: Invalid

Re: json decode issue

2011-07-14 Thread Terry Reedy
On 7/14/2011 3:20 PM, MRAB wrote: On 14/07/2011 18:22, Miki Tebeka wrote: Greetings, I'm trying to decode JSON output of a Java program (jackson) and having some issues. The cause of the problem is the following snippet: { "description": "... lives\uMOVE™ OFFERS ", } Which causes ValueError: In

Re: json decode issue

2011-07-14 Thread MRAB
On 14/07/2011 18:22, Miki Tebeka wrote: Greetings, I'm trying to decode JSON output of a Java program (jackson) and having some issues. The cause of the problem is the following snippet: { "description": "... lives\uMOVE™ OFFERS ", } Which causes ValueError: Invalid \u es

Re: json vs. simplejson

2009-05-13 Thread Thomas Heller
Ned Deily schrieb: > In article <76vs9tf1f6c5...@mid.individual.net>, > Thomas Heller wrote: >> Diez B. Roggisch schrieb: >> > Thomas Heller wrote: >> >> Python 2.6 contains the json module, which I thought was the renamed (and >> >> improved?) simplejson module that also works on older Python ve

Re: json vs. simplejson

2009-05-13 Thread Ned Deily
In article <76vs9tf1f6c5...@mid.individual.net>, Thomas Heller wrote: > Diez B. Roggisch schrieb: > > Thomas Heller wrote: > >> Python 2.6 contains the json module, which I thought was the renamed (and > >> improved?) simplejson module that also works on older Python versions. > >> > >> However,

Re: json vs. simplejson

2009-05-13 Thread Thomas Heller
Diez B. Roggisch schrieb: > Thomas Heller wrote: > >> Python 2.6 contains the json module, which I thought was the renamed (and >> improved?) simplejson module that also works on older Python versions. >> >> However, it seems the json is a lot slower than simplejson. >> This little test, run on P

Re: json vs. simplejson

2009-05-13 Thread Diez B. Roggisch
Thomas Heller wrote: > Python 2.6 contains the json module, which I thought was the renamed (and > improved?) simplejson module that also works on older Python versions. > > However, it seems the json is a lot slower than simplejson. > This little test, run on Python 2.6.2 and WinXP shows a drama

Re: JSON and Firefox sessionstore.js

2009-04-24 Thread Matt Nordhoff
Steven D'Aprano wrote: > On Thu, 23 Apr 2009 05:08:35 +0100, I V wrote: > >> For something with at least a vague air of credibility to it, somebody >> who appears to be a Mozilla developer comments on their bug tracker, >> that sessionstore.js isn't "pure JSON" (though he only identifies the >> pa

Re: JSON and Firefox sessionstore.js

2009-04-24 Thread Дамјан Георгиевски
> Unless I'm badly mistaken, the Firefox sessionstore.js file is > supposed to be JSON. ... > If it matters, I'm using Firefox 2.0.0.5 under Linux. maybe it can be parsed with PyYAML? -- дамјан ( http://softver.org.mk/damjan/ ) Well when _I_ was in school, I had to run Netscape on HP/UX, displ

Re: JSON and Firefox sessionstore.js

2009-04-22 Thread John Machin
On Apr 23, 12:16 pm, Steven D'Aprano wrote: > > The Mozilla knowledge base claims that sessionstore.js is JSON: > > http://kb.mozillazine.org/Sessionstore.js The claim is incorrect. > So does this tutorial: > > https://developer.mozilla.org/En/Firefox_addons_developer_guide/ > Let's_build_a_Fire

Re: JSON and Firefox sessionstore.js

2009-04-22 Thread Steven D'Aprano
On Thu, 23 Apr 2009 05:08:35 +0100, I V wrote: > For something with at least a vague air of credibility to it, somebody > who appears to be a Mozilla developer comments on their bug tracker, > that sessionstore.js isn't "pure JSON" (though he only identifies the > parantheses, which are much easie

Re: JSON and Firefox sessionstore.js

2009-04-22 Thread I V
On Thu, 23 Apr 2009 02:16:07 +, Steven D'Aprano wrote: > I'm leaning towards this being a bug in the json module. Unless somebody > can point me at a credible source that sessionstore.js isn't JSON, I > will report this as a bug. I'm just another random guy on the internet, but I'm pretty sure

Re: JSON and Firefox sessionstore.js

2009-04-22 Thread Steven D'Aprano
On Wed, 22 Apr 2009 21:07:46 -0400, TommW wrote: > The json files are used for bookmark backups in FF 3.0 series. That's nice to know, but I'm afraid it's irrelevant to my question. There are lots of things which are JSON. Just because *something else* is JSON does not imply that sessionstore.j

Re: JSON and Firefox sessionstore.js

2009-04-22 Thread TommW
Steven D'Aprano wrote: Unless I'm badly mistaken, the Firefox sessionstore.js file is supposed to be JSON. In Python 3.0, I do this: import json filename = '.mozilla/firefox/2z5po7dx.default/sessionstore.js' json.load(open(filename)) Traceback (most recent call last): File "/usr/local/lib/

Re: JSON and Firefox sessionstore.js

2009-04-22 Thread MRAB
Steven D'Aprano wrote: Unless I'm badly mistaken, the Firefox sessionstore.js file is supposed to be JSON. In Python 3.0, I do this: import json filename = '.mozilla/firefox/2z5po7dx.default/sessionstore.js' json.load(open(filename)) Traceback (most recent call last): File "/usr/local/lib/

Re: JSON Template: Minimal but powerful templating language implemented in Python and 3 other languages

2009-04-17 Thread Paul Rubin
Andy Chu writes: > I'm looking for some feedback based on real usage. There have been a > few small features added here and there since it was made public 3 > weeks ago, but more comments are appreciated. It looks cute, but very limited, and lacking in documentation unless I wasn't looking in th

Re: JSON from Python mysqldb

2008-08-27 Thread TYR
On Aug 27, 2:37 pm, TYR <[EMAIL PROTECTED]> wrote: > There's always the naive option. > > query = ('species', 'lifestyle', 'coolness', 'tentacles=>8') > db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query) > record = dict(zip((query), (db.fetchall())) > array = '''{ >              '''

Re: JSON from Python mysqldb

2008-08-27 Thread TYR
There's always the naive option. query = ('species', 'lifestyle', 'coolness', 'tentacles=>8') db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query) record = dict(zip((query), (db.fetchall())) array = '''{ ''' for k,v in record: array.append('"(k)":"(v)"') array.append('

Re: JSON from Python mysqldb

2008-08-26 Thread jpuopolo
On Aug 26, 3:15 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > jpuopolo wrote: > > All: > > > I am using Python to read some records from the MySQL database. I am > > using the mysqldb library, and things are working well. > > > Now, I would like to pass back the results of the query to a Web-based >

Re: JSON from Python mysqldb

2008-08-26 Thread Larry Bates
jpuopolo wrote: All: I am using Python to read some records from the MySQL database. I am using the mysqldb library, and things are working well. Now, I would like to pass back the results of the query to a Web-based front end, and I would like to use JSON. Is there a library/example of creatin

Re: JSON

2007-12-07 Thread Sion Arrowsmith
Joshua Kugler <[EMAIL PROTECTED]> wrote: >Known issue. See: >http://blog.extracheese.org/2007/07/when-json-isnt-json.html > >Neither project has fixed it it seems. Not sure which is actually >the "correct" way to do it, but it would be nice if they would agree. I think it's pretty clear (not ju

Re: JSON

2007-12-06 Thread Marc Christiansen
Joshua Kugler <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >> i tried a couple python json libraries. i used simplejson on the >> server and was using cjson on the client, but i ran into this issue. >> i'm now using simplejson on both sides, but i'm still interested in >> this issue. d

Re: JSON

2007-12-06 Thread Joshua Kugler
[EMAIL PROTECTED] wrote: > i tried a couple python json libraries. i used simplejson on the > server and was using cjson on the client, but i ran into this issue. > i'm now using simplejson on both sides, but i'm still interested in > this issue. did i do something wrong? is there a bug in one of

Re: json implementation

2006-07-25 Thread Harry George
"jon cashman" <[EMAIL PROTECTED]> writes: > Hi everyone, > > Is there a doc comparing different json implementation (example: > python-json, simplejson)? Does anyone have a strong recommendation > to make? Any problem/issue for a particular implementation? > > Thanks. > > - jon > > ___