<commit_before>package main

import (
	"encoding/csv"
	"fmt"
	"io"
	"os"

	"github.com/BatchLabs/charlatan"
	"github.com/BatchLabs/charlatan/record"
)

func main() {

	if len(os.Args) != 2 {
		usage()
		return
	}

	s := os.Args[1]

	// Creates the query

	query, err := charlatan.QueryFromString(s)
	if err != nil {
		fmt.Println(">>> ", err)
		return
	}

	reader, err := os.Open(query.From())
	if err != nil {
		fmt.Printf(">>> Error opening %s: %v\n", query.From(), err)
		return
	}

	executeRequest(csv.NewReader(reader), query)
}

func executeRequest(reader *csv.Reader, query *charlatan.Query) {

	fmt.Println("$ ", query)
	fmt.Println("$")

	var header *[]string
	line := 0

	for {

		records, err := reader.Read()
		line++

		// end of file
		if err == io.EOF {
			return
		}
		// unknown error
		if err != nil {
			fmt.Println(err)
			return
		}

		// set the header
		if header == nil {
			header = &records
			continue
		}<commit_msg>sample CSV app fixed for the recent changes<commit_after>package main

import (
	"encoding/csv"
	"fmt"
	"io"
	"os"

	"github.com/BatchLabs/charlatan"
	"github.com/BatchLabs/charlatan/record"
)

func main() {

	if len(os.Args) != 2 {
		usage()
		return
	}

	s := os.Args[1]

	// Creates the query

	query, err := charlatan.QueryFromString(s)
	if err != nil {
		fmt.Println(">>> ", err)
		return
	}

	reader, err := os.Open(query.From())
	if err != nil {
		fmt.Printf(">>> Error opening %s: %v\n", query.From(), err)
		return
	}

	executeRequest(csv.NewReader(reader), query)
}

func executeRequest(reader *csv.Reader, query *charlatan.Query) {

	fmt.Println("$ ", query)
	fmt.Println("$")

	var header []string
	line := 0

	for {

		records, err := reader.Read()
		line++

		// end of file
		if err == io.EOF {
			return
		}
		// unknown error
		if err != nil {
			fmt.Println(err)
			return
		}

		// set the header
		if header == nil {
			header = records
			continue
		}
{'fraction_non_alphanumeric': 0.1649269311064718, 'fraction_numerical': 0.003131524008350731, 'mean_word_length': 2.8963414634146343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '188318', 'n_tokens_mistral': 819, 'n_tokens_neox': 736, 'n_words': 181}