Merging Cells
Join the DZone community and get the full member experience.
Join For Free// This code reads a CSV file, takes two fields and merges them, then writes the merged field to a text file.
import csv
import os
os.chdir('Desktop')
cwd = os.getcwd()
reader = csv.reader(open('september crime data.csv', 'r'), dialect='excel')
open_file = open('streets.txt', 'w')
for row in reader:
street_number = row[9]
street_name = row[3]
open_file.write(street_number + ' ' + street_name + '\n')
open_file.close()
Opinions expressed by DZone contributors are their own.
Comments