1

I am Following Chris P's 'Visualize Real-world JSON Data in Blender (3D Chart Animation Nodes Tutorial)' on YouTube but I seem to have got stuck at the first hurdle of importing the data. I have followed his instructions completely and am unsure why the script keeps failing. I have attached his script, My script, my file location, my error message and a snap shot of his video. I am On windows OS, he is on Linux I'menter image description here not sure if that makes a difference. Here is the link to the video: https://www.youtube.com/watch?v=0aRjInmibSw&t=1055s THE TIMESTAMP FOR HIS CODE IS 6 min.

FILE NAME: Export.json

MY FILE LOCATION: C:\Users\Jordan\Downloads

MY CODE

import json

with open(r'C:/Users/Jordan/Downloads/Export.json','r') as f: 
      j=json.load(f) 
      print (j) 

MY ERROR MESSAGE:

Traceback (most recent call last):
  File "D:\Mixed Graphs\Blender json\3D Charts.blend\My Script", line 3, in <module>
OSError: [Errno 22] Invalid argument: '/C:/Users/Jordan/Downloads/Export'
Error: Python script failed, check the message in the system console

HIS CODE:

import json

with open('/Home/chris/downloads/tutorial1.json') as f: 
    json.load(f) 
    print (j) 
7
  • Typo. '/C:/Users/...' should just be 'C:/Users/...'. Commented Nov 5, 2020 at 17:31
  • I have just changed it but it still seems to be displaying the same error message unfortunately. Thank you for the super fast reply though!!!! Commented Nov 5, 2020 at 17:34
  • Well, print (j) is going to fail because you never defined j. Did you mean to put j = json.load(f)? As for the invalid argument error, do you still get it if you use backslashes instead? You'll have to prepend r to the string like r'C:\Users\...'. Also add 'r' to your open, like with open('path', 'r') as f: Commented Nov 5, 2020 at 17:40
  • import json with open(r'C:\Users\Jordan\Downloads\Export.json','r') as f: j=json.load(f) print (j) I've tried both ways and it still cant seem to find the file. Thanks for commenting though :) Also I cant seem to format these comments very well I apologise for that. Commented Nov 5, 2020 at 17:50
  • I'd recommend updating the question itself with your updated code, actually. Also are you still getting the same error or is it a different one? Commented Nov 5, 2020 at 18:02

1 Answer 1

0

Your problem seems to be that you're using "/"(slash) instead of ""(backslash) on Windows. In addition you need to use two "\" as one backslash signals an escaping for the next character.

Fix therefore should be:

import json

with open(r'C:\\Users\\Jordan\\Downloads\\Export.json','r') as f: 
      j=json.load(f) 
      print (j)
Sign up to request clarification or add additional context in comments.

Comments

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.