Over a million developers have joined DZone.

Merging Cells

·
// 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()

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}