Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CSV File not found
#11
New error

Quote:49.5
C:Users\Owner\Desktop\Blender\Probot 2
Traceback (most recent call last):
File "C:\Users\Owner\Desktop\Blender\Probot 2\ProbotPositions.blend\Text", line 23, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.79\python\lib\pathlib.py", line 1151, in open
opener=self._opener)
TypeError: an integer is required (got type str)
Error: Python script fail, look in the console for now...

import bpy

ob1 = bpy.data.objects["Base"]
ob2 = bpy.data.objects["Middle Arm"]
ob3 = bpy.data.objects["Top Arm"]

ob1Strt = 0
ob1Dist = 1.5
ob1FrmEnd = ob1Dist*33

print (ob1FrmEnd)

from pathlib import Path
p = Path('C:')/'Users'/'Owner'/'Desktop'/'Blender'/'Probot 2'
print(str(p))


import csv

line = 1
column = 2

with p.open('Program.txt', 'r') as file:
    mycsv = csv.reader(file)
    mycsv = list(mycsv)
    text = mycsv[line][column]
    print(text)
    rotate=int(text)
Reply
#12
(Jan-30-2018, 06:53 AM)SeanBassett Wrote: New error
p must be the path to Program.txt, not to Probot 2, also if you write p.open('r'), you must not write the file's name
Reply
#13
Still not working.

Error:
Quote:49.5
C:Users\Owner\Desktop\Blender\Probot 2\Program.txt
Traceback (most recent call last):
File "C:\Users\Owner\Desktop\Blender\Probot 2\ProbotPositions.blend\Text", line 23, in <module>
AttributeError: __exit__
Error: Python script fail, look in the console for now...

import bpy

ob1 = bpy.data.objects["Base"]
ob2 = bpy.data.objects["Middle Arm"]
ob3 = bpy.data.objects["Top Arm"]

ob1Strt = 0
ob1Dist = 1.5
ob1FrmEnd = ob1Dist*33

print (ob1FrmEnd)

from pathlib import Path
p = Path('C:')/'Users'/'Owner'/'Desktop'/'Blender'/'Probot 2/Program.txt'
print(str(p))

import csv
line = 1
column = 2

with p.open as file:
    mycsv = csv.reader(file)
    mycsv = list(mycsv)
    text = mycsv[line][column]
    print(text)
    rotate=int(text)
Reply
#14
It isp.open(), not p.open.
Reply
#15
new error

Quote:49.5
C:Users\Owner\Desktop\Blender\Probot 2\Program.txt
Traceback (most recent call last):
File "C:\Users\Owner\Desktop\Blender\Probot 2\ProbotPositions.blend\Text", line 21, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.79\python\lib\pathlib.py", line 1151, in open
opener=self._opener)
File "C:\Program Files\Blender Foundation\Blender\2.79\python\lib\pathlib.py", line 1005, in _opener
return self._accessor.open(self, flags, mode)
File "C:\Program Files\Blender Foundation\Blender\2.79\python\lib\pathlib.py", line 371, in wrapped
return strfunc(str(pathobj), *args)
FileNotFoundError: [Errno 2] No such file or directory: 'C:Users\\Owner\\Desktop\\Blender\\Probot 2\\Program.txt'
Error: Python script fail, look in the console for now...
Reply
#16
Replace C: with C:/
Reply
#17
new error after adding
Quote:C:/

Error:
Traceback (most recent call last): File "\Text", line 3, in <module> KeyError: 'bpy_prop_collection[key]: key "Base" not found' Error: Python script fail, look in the console for now...
Reply
#18
This is an error in the line
ob1 = bpy.data.objects["Base"]
I cannot debug this for you, I don't know the bpy module. You'll have to figure out why bpy.dat.objects has no key "Base".

Anyway it is your duty as a programmer to debug the code yourself...
Reply
#19
Thank you so much for all the help. It now works.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Absolute paths in subprocess - file not found kittyticker 4 477 Jan-28-2024, 10:37 PM
Last Post: kittyticker
  file open "file not found error" shanoger 8 1,084 Dec-14-2023, 08:03 AM
Last Post: shanoger
  File not found error saisankalpj 10 3,819 Jul-04-2022, 07:57 AM
Last Post: saisankalpj
  How can I found how many numbers are there in a Collatz Sequence that I found? cananb 2 2,533 Nov-23-2020, 05:15 PM
Last Post: cananb
  File not found error Ads 5 3,254 Mar-15-2020, 01:56 PM
Last Post: saqib1066
  modify line in file if pattern found in list. kttan 1 2,214 Dec-10-2018, 08:45 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020