
def data_to_scl(file_name):

    header = 'insert into species (species_id, species_name, genus_id, description, average_length, average_weight, primary_color) values \n'
    end_sql = '\n);'

    new_file = open('sql.txt', 'w')
    new_file.write(header)

    with open(file_name, 'r') as file:
        for line in file:
            data = line.split('|')
            new_list = []
            
            # new_list.append('(' + data[1].strip() + ',\n')
            new_list.append("('" + data[2].strip() + "',\n")
            new_list.append(data[3].strip() + ',\n')
            new_list.append("'" + data[4].strip() + "',\n")
            new_list.append(data[5].strip() + ',\n')
            new_list.append(data[6].strip() + ',\n')
            new_list.append("'" + data[7].strip() + "'),\n")
            

            for new in new_list:
                new_file.write(new)

            # new_file.write('),(\n') 

    new_file.write(end_sql)
    new_file.close()
    


def main():
    data_to_scl('data.txt')



if __name__ == '__main__':
    main()