CSV, TSV ve Txt yi Excel e dönüştür
CSV Dosyalarını Açma
Virgülle Ayrılmış Değerler (CSV) dosyaları, değerlerin virgülle ayrıldığı kayıtları içerir. Veri, her sütunun virgül karakteriyle ayrıldığı ve çift tırnak karakteriyle alıntılanmış bir tablo olarak saklanır. Bir alan değeri çift tırnak karakteri içeriyorsa, çift tırnak karakteriyle kaçış yapılır. Elektronik tablo verilerini CSV’ye aktarmak için Microsoft Excel’i de kullanabilirsiniz.
from aspose.cells import LoadFormat, LoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions4 = LoadOptions(LoadFormat.CSV) | |
# Create a Workbook object and opening the file from its path | |
wbCSV = Workbook(dataDir + "Book_CSV.csv", loadOptions4) | |
print("CSV file opened successfully!") |
CSV Dosyalarını Açma ve Geçersiz Karakterleri Değiştirme
Excel’de, özel karakter içeren CSV dosyası açıldığında karakterler otomatik olarak değiştirilir. Aynı işlem, kod örneğinde gösterildiği gibi Aspose.Cells API tarafından da yapılır.
from aspose.cells import LoadDataFilterOptions, LoadFilter, TxtLoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
filename = sourceDir + "[20180220142533][ASPOSE_CELLS_TEST].csv" | |
options = TxtLoadOptions() | |
options.separator = ';' | |
options.load_filter = LoadFilter(LoadDataFilterOptions.CELL_DATA) | |
options.check_excel_restriction = False | |
options.convert_numeric_data = False | |
options.convert_date_time_data = false | |
# Load CSV file | |
workbook = Workbook(filename, options) | |
print(workbook.worksheets[0].name) | |
print(len(workbook.worksheets[0].name)) | |
print("CSV file opened successfully!") |
Sekmeyle Ayrılmış Dosyaları Açma
Sekmeyle Ayrılmış (Metin) dosyası biçimlendirme olmadan elektronik tablo verileri içerir. Veri, tablolar ve elektronik tablolar gibi satırlar ve sütunlar halinde düzenlenir. Temelde, sekmeyle ayrılmış dosya, her sütun arasında bir sekme olan bir tür düz metin dosyasıdır.
from aspose.cells import LoadFormat, LoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Opening Tab Delimited Files | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions5 = LoadOptions(LoadFormat.TAB_DELIMITED) | |
# Create a Workbook object and opening the file from its path | |
wbTabDelimited = Workbook(dataDir + "Book1TabDelimited.txt", loadOptions5) | |
print("Tab delimited file opened successfully!") |
Sekmeyle Ayrılmış Değerler (TSV) Dosyalarını Açma
Sekmeyle ayrılmış değerler (TSV) dosyası biçimlendirme olmadan elektronik tablo verileri içerir. Veri, tablolar ve elektronik tablolar gibi satırlar ve sütunlar halinde düzenlenir. Veri, tablo ve elektronik tablo gibi satırlar ve sütunlar halinde düzenlenir.
from aspose.cells import LoadFormat, LoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions = LoadOptions(LoadFormat.TSV) | |
# Create a Workbook object and opening the file from its path | |
workbook = Workbook(sourceDir + "SampleTSVFile.tsv", loadOptions) | |
# Using the Sheet 1 in Workbook | |
worksheet = workbook.worksheets[0] | |
# Accessing a cell using its name | |
cell = worksheet.cells.get("C3") | |
print("Cell Name: " + cell.name + " Value: " + cell.string_value) |