Q: Exporting JSON API result into a CSV file I'm trying to export JSON API result into a CSV file. And I am having a formatting issue in CSV.
JSON API result

{'CASSReportLink': 'https://smartmover.melissadata.net/v3/Reports/CASSReport.aspx?tkenrpt=YvBDs39g52jKhLJyl5RgHKpuj5HwDMe1pE2lcQrczqRiG3/3y5yMlixj5S7lIvLJpDyAOkD8fE8vDCg56s3UogNuAkdTbS2aqoYF5FvyovUjnXzoQaHaL8TaQbwyCQ2RB7tIlszGy5+LqFnI7Xdr6sjYX93FDkSGei6Omck5OF4=', 'NCOAReportLink': 'https://smartmover.melissadata.net/v3/Reports/NCOAReport.aspx?tkenrpt=8anQa424W7NYg8ueROFirapuj5HwDMe1pE2lcQrczqRiG3/3y5yMlixj5S7lIvLJpDyAOkD8fE8vDCg56s3UogNuAkdTbS2aqoYF5FvyovUjnXzoQaHaL8TaQbwyCQ2RB7tIlszGy5+LqFnI7Xdr6sjYX93FDkSGei6Omck5OF4=', 'Records': [{'AddressExtras': '', 'AddressKey': '78704,78704', 'AddressLine1': '                                                            ,                                                            ,                                                            ,STE C-100                                                   ', 'AddressLine2': '1009 W MONROE ST                                            ,1600 S 5TH ST                                               ,1008 W MILTON ST                                            ,3939 BEE CAVES RD                                           ', 'AddressTypeCode': '', 'BaseMelissaAddressKey': '', 'CarrierRoute': '', 'City': 'Austin                                            ,Austin                                            ,Austin                                            ,Austin                                            ', 'CityAbbreviation': 'Austin                                            ,Austin                                            ,Austin                                            ,Austin                                            ', 'CompanyName': '', 'CountryCode': 'US', 'CountryName': 'United States', 'DeliveryIndicator': '', 'DeliveryPointCheckDigit': '', 'DeliveryPointCode': '', 'MelissaAddressKey': '', 'MoveEffectiveDate': '', 'MoveTypeCode': '', 'PostalCode': '78704,78704,78704,78746', 'RecordID': '1', 'Results': 'AE07', 'State': '', 'StateName': 'TX                                                ,TX                                                ,TX                                                ,TX                                                ', 'Urbanization': ''}], 'TotalRecords': '1', 'TransmissionReference': '1353', 'TransmissionResults': '', 'Version': '4.0.4.48'}
  [Finished in 2.6s]

Python query
r = response.json()


output_1 = []
output_1.append("AddressLine2")

# Collect only Address Line 2 from the JSON output. properly encode/decode the string and add it to output_1. 
for record in r['Records']:
    addressline2 = record['AddressLine2']
    addressline2.split(",")
    print(addressline2)
    output_1.append(addressline2)

print(output_1)

# Write the values to a column
with open(r"C:\users\testu\documents\travis_output.csv", 'w') as fp:
    writer = csv.writer(fp, dialect = 'excel')
    for val in output_1:
        writer.writerow([val])

Result I am getting

Result I want

I thought addressline2.split(",") should do its job but it didn't work. Thanks for any help!

A: this would give you your result:
output_1 += addressline2.split(",") 


A: You are running addressline2.split(","), but you aren't using the output of that operation in your CSV, instead you're just re-using addressline2 again. The split method creates a new variable as the output of the function, it doesn't transform the original variable into a list.
You need to capture the output, e.g.
output_1.append(addressline2.split(","))

