(data []byte)
| 201 | } |
| 202 | |
| 203 | func 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 |
| 229 | func ProcessCSV(ctx context.Context, uploadID, source string, reader io.Reader, store StoreFunc) (int, error) { |
no outgoing calls
no test coverage detected