0

I have a json file from which i want to retrieve on particular values into dataframe columns like

    {'Benot':'50455','Madri':'18017','Madrar':'Ossur','Application':'Soft Top Post-op Shoe','Color':'Black','FasteningType':'Contact Closure','Material':'Cotton / Polyester','ShoeSize':'Male 9 to 11','Size':'Large','Style':'Open Toe / Closed Heel','Code':'42241709','User':'Male'}    
    {'Benot':'501455','Madri':'180117','Madrar':'Osur','Application':'SoftShoe','Color':'Black','Material':'Cotton / Polyester','ShoeSize':'Male 9 to 11','Size':'Large','Code':'42241709','User':'Male'}

The problem is the same data is not present inside every {} like in 'ShoeSize':'Male 9 to 11' is preset in one line but not in other line and for many other field

I just want to read 'Benot' , 'Madri' ,'Madrar' , 'Application', 'Code' is there any possible way to read only this in dataframe when i read file it throws error

         data = pd.read_csv('McKessonFullData.txt')
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 9: invalid continuation byte 

Is it possible to read particular values save it dataframe

1 Answer 1

1

It seems you need read_json with lines=True:

data = pd.read_json('McKessonFullData.txt', lines=True)
Sign up to request clarification or add additional context in comments.

5 Comments

throws error ValueError: Expected object or value as i want to read only particular value from the field so i think reading as a text file and then reading particular value from it
@ParthTiwari - Are data confidental? If not, i spossible share file? Because if some encoding problem the best is working with original data
no its not confidential where should i share the file
@ParthTiwari - Super, then use gdocs, dropbox, wetransfer or similar
somehow i am not able to attach the file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.