MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / LooksLikeCSV

Function LooksLikeCSV

internal/files/files.go:203–226  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

201}
202
203func LooksLikeCSV(data []byte) bool {
204 lines := bytes.Split(data, []byte("\n"))
205 if len(lines) < 2 {
206 return false
207 }
208
209 fields := bytes.Count(lines[0], []byte(",")) + 1
210 // Only check first few lines for performance
211 maxLinesToCheck := 5
212 if len(lines) < maxLinesToCheck {
213 maxLinesToCheck = len(lines)
214 }
215
216 for _, line := range lines[1:maxLinesToCheck] {
217 if len(line) == 0 {
218 continue
219 }
220 if bytes.Count(line, []byte(","))+1 != fields {
221 return false
222 }
223 }
224
225 return fields > 1
226}
227
228// ProcessCSV now uses parallel processing with workers
229func ProcessCSV(ctx context.Context, uploadID, source string, reader io.Reader, store StoreFunc) (int, error) {

Callers 1

AnalyzeTextContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected