Beispiel #1
0
#Open stream to the source file path
source_file = ManipulateFile.Open_existing_file(source_file_path)
source_lines = []
out_lines = []
out_error_lines = []
# brand = ""
model = ""
type = ""
count = 0
out = None

if source_file != None:
    with source_file as source:
        csv_reader = csv.reader(source, delimiter=';')
        for row in csv_reader:
            source_lines.append(LineSource(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7]))

        if len(source_lines) < 5:
            print("Le fichier sélectionné contient trop peu de lignes pour être utilisé")
        else:
            for line in source_lines:
                if line.is_empty == False:
                    if line.is_title:
                        if Contain_type(line.designation):
                            type = Upper_first_letter_word(Get_type(line.designation))
                        if Contain_model(line.designation) and (source_lines[count+1].is_empty == False and source_lines[count+1].is_title == False) and source_lines[count-1].is_empty == True:
                            model = Upper_first_letter_word(Get_model(line.designation))
                    else:
                        out = Out(line.reference_client, line.reference_sap, Upper_first_letter_word(line.designation) + " " + str(line.capacity) + " ML", line.capacity, line.cnt_product_pack, line.barcode, line.buy_price, line.sell_price, Upper_first_letter_word("test"), Upper_first_letter_word("test"), Upper_first_letter_word("test"))
                        if out != None:
                            out_lines.append(out)
from Out import Out
import csv

#Get the source file path
source_file_path = ManipulateFile.Select_file()

#Open stream to the source file path
source_file = ManipulateFile.Open_existing_file(source_file_path)
source_lines = []
out_lines = []

if source_file != None:
    with source_file as source:
        csv_reader = csv.reader(source, delimiter=';')
        line_count = 0
        for row in csv_reader:
            source_lines.append(
                LineSource(row[0], row[1], row[2], row[3], row[4], row[5],
                           row[6], row[7]))

        for source_line in source_lines:
            sl = source_line
            out = Out(sl.reference_client, sl.reference_sap,
                      sl.designation + " " + sl.capacity, sl.capacity,
                      sl.cnt_product_pack, sl.barcode, sl.buy_price,
                      sl.sell_price, "test", "test", "test")
            if out.is_ok:
                print(out)

else:
    print("Impossible d'ouvrir le fichier sélectionné, veuillez ré-essayer")