Here is an alternative solution. It reads in a tab-delineated .ascii file (which is very similar to a .txt file) which it assumes has headers of Longitude and Latitude. I came across this question and then ended up with this solution so I figured that it can probably help someone.
# ------------------------------------------------------
# IMPORTS
# ------------------------------------------------------
import os
import pandas as pd
from shapely.geometry import Point, mapping
from fiona import collection
# ------------------------------------------------------
# INPUTS
# ------------------------------------------------------
# Define path
path = os.path.abspath(os.path.dirname(__file__))
# Set working directory
os.chdir(path)
# Define file to convert
file = 'points.ascii'
# Define shp file schema
schema = { 'geometry': 'Point', 'properties': { 'LocationID': 'str', 'Latitude': 'float', 'Longitude': 'float' } }
# Read in data
data = pd.read_csv(file, sep='\t')
# Define shp file to write to
shpOut = 'points.shp'
# Create shp file
with collection(shpOut, "w", "ESRI Shapefile", schema) as output:
# Loop through dataframe and populate shp file
for index, row in data.iterrows():
# Define point
point = Point(row['Longitude'], row['Latitude'])
# Write output
output.write({
'properties': {'LocationID': row['LocationID'], 'Latitude': row['Latitude'], 'Longitude': row['Longitude'] },
'geometry': mapping(point)
})