fb8a3f5658
- Introduced exact arithmetic with support for large integers and fractions in `exact.gd`, `big_integer.gd`, and `exact_value.gd`. - Implemented a comprehensive test suite in `test_exact_math.gd` to validate arithmetic operations against expected results. - Added a README in `math` directory to document the exact arithmetic system and its usage. - Ensured that all arithmetic operations maintain precision without floating-point errors, using a custom representation for large numbers. - Included methods for encoding and decoding exact values for serialization.
37 lines
847 B
GDScript
37 lines
847 B
GDScript
class_name CSVLoader
|
|
|
|
|
|
static func load(csv_text: String) -> Array[Dictionary]:
|
|
var rows: Array[Dictionary] = []
|
|
|
|
var lines := csv_text.strip_edges().split("\n")
|
|
|
|
if lines.size() < 2:
|
|
return rows
|
|
|
|
var headers := lines[0].split(",")
|
|
|
|
for i in range(1, lines.size()):
|
|
var line := lines[i].strip_edges()
|
|
|
|
if line.is_empty():
|
|
continue
|
|
|
|
var values := line.split(",")
|
|
|
|
if values.size() != headers.size():
|
|
push_warning(
|
|
"CSV row %d has %d columns, expected %d"
|
|
% [i + 1, values.size(), headers.size()]
|
|
)
|
|
continue
|
|
|
|
var row: Dictionary = {}
|
|
|
|
for j in range(headers.size()):
|
|
row[headers[j].strip_edges()] = values[j].strip_edges()
|
|
|
|
rows.append(row)
|
|
print(rows)
|
|
return rows
|