MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / format_csv

Method format_csv

gql-cli/src/cli/output.rs:122–153  ·  view source on GitHub ↗

Format results as CSV

(result: &QueryResult)

Source from the content-addressed store, hash-verified

120
121 /// Format results as CSV
122 fn format_csv(result: &QueryResult) -> String {
123 let mut output = String::new();
124
125 // CSV header
126 output.push_str(&result.variables.join(","));
127 output.push('\n');
128
129 // CSV rows
130 for row in &result.rows {
131 let row_values: Vec<String> = result
132 .variables
133 .iter()
134 .map(|col| {
135 row.get_value(col)
136 .map(Self::value_to_csv_string)
137 .unwrap_or_else(|| "".to_string())
138 })
139 .collect();
140 output.push_str(&row_values.join(","));
141 output.push('\n');
142 }
143
144 // Add warnings as CSV comments
145 if !result.warnings.is_empty() {
146 output.push_str("\n# Warnings:\n");
147 for (i, warning) in result.warnings.iter().enumerate() {
148 output.push_str(&format!("# {}. {}\n", i + 1, warning));
149 }
150 }
151
152 output
153 }
154
155 /// Convert a Value to a display string
156 fn value_to_string(value: &Value) -> String {

Callers

nothing calls this directly

Calls 3

get_valueMethod · 0.80
iterMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected