# Blender not accepting CSV file [duplicate]

CSV File Not Supported Error dealt with the error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 23:
invalid continuation byte


Now there is a different problem. The code is:

import bpy
import csv
import sys

file = open('test.csv', 'rU', 'ignore')


The error message is:

TypeError: an integer is required (got type str)
Error: File format is not supported in file '/PI-SAT/proj001/test.csv'


I have verified that test.csv is a valid .csv file by running a different script:

import csv

path = "test.csv"
file = open(path,'rU')

data = []
name0 = row[0]
name1 = row[0]
vid_file = 'test-videos/' + row[5] + '.m4v'
cli_line = name0 + '", "' + name1 + '", "' + vid_file
print(cli_line)


This runs exactly as expected as a stand alone Python script.

What is causing the error when I attempt to run the code as a Python script in Blender?

• Please do not ask duplicate questions just because you did not get satisfactory answers on the first. – David Sep 30 '18 at 13:37

In the first example, you tell the open function to ignore errors with open(..., 'ignore') . If a file is not found, it will have the behavior that you mentioned:

TypeError: an integer is required (got type str)


Also, the U mode is deprecated, so you probably shouldn't be using it.

A reasonable possibility is that where you are running it in Blender, the current working directory is different than what you think it is. Try printing out the result of os.getcwd() and os.listdir() like so:

import os

print(os.getcwd())   # current directory
print(os.listdir())  # files in current directory

• I modified the code to work in Blender and got: Read blend: /PI-SAT/proj001/proj001-master.blend /PI-SAT/proj001 ["'pathout'", '__init__.py', 'b-csv-test.py', 'blank.blend', 'blank.blend1', 'blender', 'c-csv-test.py', 'csv-test.py', 'd-csv-test.py', 'env', 'lib', 'master_csv_render.py', 'oauth.py', 'pathout', 'pathout.m4v', 'proj001-master .blend.save', 'proj001-master.blend', 'proj001-master.blend1', 'proj001auto.py', 'proj001auto.py.save', 'proj001master.py', 'test-videos', 'test.blend', 'test.csv', 'testreadauto.py', 'testsubprocess.py'] Blender quit – mcgeo52 Sep 28 '18 at 23:34
• I am in the correct directory, and the file is there. – mcgeo52 Sep 28 '18 at 23:40
• @mcgeo52 I don't know exactly what you are doing...and your question is missing some detail. Could you edit your question to explain what you are trying to accomplish and where/how exactly you are running your Python script? – JakeD Sep 29 '18 at 1:31

I was testing on the Mac. I have moved the project to Google Cloud and the program runs properly on Google Compute Engine.