0

I am facing with the following error while reading json from file

    json.decoder.JSONDecodeError: Expecting ',' delimiter: line 2 column 1 (char 948)

The json content is read from file using the script below

import json
if __name__ == "__main__":

     file_path = "D:\\Freelancing\\Scraping_football_historic_data\\Data\\1.138103502"

     with open(file_path,'r') as datafile:

         dict_data = json.load(datafile)

     print(dict_data) 

Upon searching for answer, this question had an answer that suggested me to add r before the json string.

How can it be done in the case above, or if there's a better way to read the file. ?

The contents of the file can be read from the pastebin link: https://pastebin.com/ZyyrtcZW

2
  • 2
    The data in the file is not valid JSON; it looks like each line should maybe have a trailing comma. Adding r won't help anything. Commented Mar 23, 2019 at 22:35
  • the comma's are to represent list of dicts? Commented Mar 23, 2019 at 22:41

1 Answer 1

1

You are missing a comma between each of your individual dictionaries, your data should look like

....
{"op":"mcm","clk":"5733948534","pt":1514206953689,"mc":[{"id":"1.138103502","rc":[{"ltp":2.02,"id":48756}]}]},
{"op":"mcm","clk":"5739085003","pt":1514309273736,"mc":[{"id":"1.138103502","rc":[{"ltp":2.0,"id":48756}]}]},
{"op":"mcm","clk":"5739711407","pt":1514327265235,"mc":[{"id":"1.138103502","rc":[{"ltp":2.06,"id":48756}]}]},
.....
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.