To export using the csv module we:
import csv
data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
output_file = open('./data/examp_output.txt', 'w')
datawriter = csv.writer(output_file)
datawriter.writerows(data)
output_file.close()
In Numpy the export is just a single line use savetxt()
import numpy as np
data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
np.savetxt('./data/examp_output.txt', data, delimiter = ',')
Using Pandas, the data frame has a method to_csv that allows writing to delimited text. The default in Pandas is to include column names and the index and so the output is somewhat different for this example than the other approaches.
import pandas as pd
data = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
data.to_csv('./data/examp_output.txt')