Beruflich Dokumente
Kultur Dokumente
#----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------
# Import the output file into the following Directory. Setting up connection with
the following directory.
import os
if os.path.exists (r'C:\temp\d1Result'):
import shutil
shutil.rmtree (r'C:\temp\d1Result')
if fieldNames == 1:
# Define variable for the header row.
titleRow =
'FarmID\tAddress\tStreetNum\tStreetName\tSufType\tDir\tCity\tProvince\tPostalCode\n
'
outFileHandler.write(titleRow)
#Defining variables and splitting strings for all 9 column in the output file based
on tabs, lines and spaces.
else:
#Define removeN to start data on second line.
removeN = line.rstrip('\n')
#Define farm ID as first value in row and than include a tab.
farmID = removeN.split ('\t')[0]
#Define address as second value in row and than include a tab.
address = removeN.split ('\t') [1]
#Define splitAddress as first value from "address" delimited by a comma and space.
splitAddress = address.split (', ') [0]
#Define city as second value from "address" delimited by a comma and space.
city = address.split (', ') [1]
#Define Province as third value from "address" delimited by a comma and space.
Province = address.split (', ') [2]
#Define splitAddress0 as second word delimited by space from "splitAddress".
splitAddress0 = splitAddress.split (' ')
#Define streetNumField as the first string from "splitAdress0".
streetNumField = splitAddress0 [0]
#Define streetNameField as the second and third string from "splitAddress0".
streetNameField = splitAddress0[1:-1]
else:
streetName = streetNameField[0]
#If there is no direction then define streetSufField as one string behind the end
of
#of "splitAddress0" and define streetNameField as ranging from the two words behind
"splitSufField".
else:
streetDirField = ' '
streetSufField = splitAddress0[-1]
streetNameField = splitAddress0 [1:-1]
#If the count value is less than the Street Name field than include a space between
the first and second word.