Blender 2.79 on Mac Os 10.12 import csv data using Python Most advice on importing csv files seems to assume users are on Windows, not Mac and many hours of effort has not helped this noobie to figure out the Mac setup and paths to import csv files to Blender text window. So I'm thinking just create a big string as below outside Blender and paste into Blender Python text window and then program a way to convert this string to a list(lines of data) of lists(variables). Does this make sense? Simple enough but somewhat defeatist!

CSV FILE 5 LINES
number,y,x,z,m
1,0,0.44,8.19,11.21
2,-11.68,8.13,8.31,7.22
3,-1.54,1.42,5.93,2.16
4,-7.1,3.13,6.25,1.42
5,5.17,3.13,8,1.39

(REAL DAT WILL BE 1000+ LINES)

MANUALLY CONVERT TO A LONG STRING
quakeTxt="1,0,0.44,8.19,11.212,-11.68,8.13,8.31,7.223,-1.54,1.42,5.93,2.164,-7.1,3.13,6.25,1.425,5.17,3.13,8,1.39"

PASTE INTO BLENDER

Because the script below doesn't work

import os
import bpy

blendPath = /Users/dickmeehan/Desktop
fileName = "xyzevents.csv" # name of the csv which is on Desktop

txt = open(blendPath + fileName, "r") # open the file to read
quakeTxt = txt.read() # read the entire file into a string
txt.close() # close the file
print(quakeTxt)
Use the os.path module 

I'm not on a mac.  The code you posted wont work on any os, unless you have a "/Users/dickmeehan/Desktopxyzevents.csv" csv file in your user folder.

import os

dirpath = "/Users/dickmeehan/Desktop"
filename = "xyzevents.csv"

filepath = os.path.join(dirpath, filename)
txt = open(filepath, "r")
quaketxt = txt.read()

txt.close()
print(quaketxt)


Note: If the blend file is saved then the folder it is in is 

blenfolder = os.path.dirname(bpy.data.filepath)


Use the filebrowser   

To avoid having to hardcode in paths altogether, open Text Editor &gt; Templates &gt; Operator File Import and edit any occurences of ".txt" to ".csv". (approx line 28)

# ImportHelper mixin class uses this
filename_ext = ".csv"

filter_glob = StringProperty(
        default="*.csv",
        options={'HIDDEN'},
        maxlen=255,  # Max internal buffer length, longer would be clamped.
        )


run the script, select the file... and bingo prints the selected csv file to system console.  Edit the read_some_data(..) method to suit.

Use the Text Editor

open the csv file in a text block (or paste into new  and rename)

for line in bpy.data.texts["xyzevents.csv"].lines:
    print(line.body)


Lastly

There is no need to convert to some unwieldy string.

csvtext = '''
number,y,x,z,m
1,0,0.44,8.19,11.21
2,-11.68,8.13,8.31,7.22
3,-1.54,1.42,5.93,2.16
4,-7.1,3.13,6.25,1.42
5,5.17,3.13,8,1.39
'''

print(csvtext)