Новый перевод английской версии сайта
This commit is contained in:
+22
-16
@@ -1,45 +1,51 @@
|
||||
### Working with CsvManager
|
||||
|
||||
This class is designed to write and extract information from csv files
|
||||
This class is intended for writing and retrieving information from CSV files.
|
||||
|
||||
The CsvManager class takes three arguments: the newline character newline (default is an empty string), the encoding of the opened files encoding (default is UTF-8), and the delimiter used in the CSV file delimiter (default is ";").
|
||||
The CsvManager class accepts three arguments:
|
||||
|
||||
- newline — the newline character (default is an empty string).
|
||||
|
||||
- encoding — the encoding of the files being opened (UTF-8).
|
||||
|
||||
- delimiter — the delimiter used in the CSV file (;).
|
||||
|
||||
```py
|
||||
|
||||
from ipars import CsvManager
|
||||
|
||||
c = CsvManager()
|
||||
c = CsvManager(newline="", encoding="UTF-8", delimiter=";")
|
||||
```
|
||||
|
||||
### Brief Overview of CsvManager Methods
|
||||
|
||||
1. The **writerow** method writes a row to the CSV file. The method takes the path to the CSV file, the write mode, and a list of data that will be written to the file's row.
|
||||
- The **writerow** method writes a row to a CSV file. This method accepts the file path, the write mode, and a list of data to be written in the row.
|
||||
|
||||
2. The **writerows** method takes the same arguments as writerow, but the row must be a double list with data for writing. The difference between these methods is that writerow writes one row, while writerows writes as many as there are in the double list.
|
||||
- The **writerows** method accepts the same arguments as writerow, except row must be a double list with data for writing. The difference between these methods is that writerow writes one row, while writerows writes as many rows as there are in the double list.
|
||||
|
||||
3. The **getRows** method is used to retrieve a list of rows in the CSV file. The method takes the path to the file from which the rows will be obtained.
|
||||
- The **getRows** method is used to obtain a list of rows from the CSV file. This method accepts the file path from which the rows will be retrieved.
|
||||
|
||||
4. The **pprint** method is the same as that of Pars.
|
||||
- The **pprint** method is the same as that of Pars.
|
||||
|
||||
### Example of Using CsvManager
|
||||
### Example Usage of CsvManager
|
||||
|
||||
```py
|
||||
from ipars import CsvManager
|
||||
c = CsvManager()
|
||||
nameFile = 'data.csv'
|
||||
|
||||
# writing headers
|
||||
writer = c.writerow('./data.csv', 'w', ['Quantity', 'Price', 'Total'])
|
||||
# Writing headers
|
||||
c.writerow(nameFile, 'w', ['Quantity', 'Price', 'Total'])
|
||||
|
||||
# writing data
|
||||
writer = c.writerows('./data.csv', 'a', [
|
||||
# Writing data
|
||||
c.writerows(nameFile, 'a', [
|
||||
["5", "5", "25"],
|
||||
["6", "6", "36"],
|
||||
["7", "7", "49"],
|
||||
])
|
||||
|
||||
# retrieving rows from the table
|
||||
rows = c.getRows('./data.csv')
|
||||
# Retrieving rows from the table
|
||||
rows = c.getRows(nameFile)
|
||||
|
||||
# printing table rows
|
||||
# Displaying the rows of the table
|
||||
c.pprint(rows)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user