<commit_before>#!/bin/bash
MODE="rais"

if [ -z "$1" ]
  then
    echo "** ERROR: No directory supplied. Please specify absolute path to folder.";
    exit -1;
fi

# -- one parameter required absolute path to folder
FOLDER=$1

# for fullpath in $FOLDER/*.tsv.bz2
# for tbl in yb ybi ybio ybo yi yio yo
for tbl in yi yo
do
    # echo "Full path: $fullpath";
    # filename=$(basename $fullpath)
    # tsvname="${filename%.bz2}";
    filename="$FOLDER/$tbl.tsv.bz2";
    tsvname="${filename%.bz2}";
    echo $tsvname
    
    # -- Unzip
    echo "Unzipping to $tsvname ..."
    bzcat $filename > $tsvname
   
    # tsvpath="$FOLDER/$tsvname"
   
    # -- Import to database
    tablename="${MODE}_$tbl";
    echo "Importing $tsvname to SQL table $tablename";
   
    # -- Take the first line of the tsv and convert tabs to commas so we can map tsv fields -> mysql columns
    fields=`head -1 $tsvname | tr '\t' ','`
    echo $fields;
    mysql -uroot $DATAVIVA2_DB_NAME -e "LOAD DATA LOCAL INFILE '$tsvname' INTO TABLE $tablename FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' IGNORE 1 LINES ($fields);";
   
    # -- Clean up tmp file
    rm $tsvname;
    echo "Completed import to $tablename";
done
 


<commit_msg>users can specify specific tables to import<commit_after>#!/bin/bash
MODE="rais"

if [ -z "$1" ]
  then
    echo "** ERROR: No directory supplied. Please specify absolute path to folder.";
    exit -1;
fi
FOLDER=$1

if [ -z "$2" ]
  then
    echo "** ERROR: please specify tables.";
    exit -1;
fi
TABLES=$2
IFS='_'


# for fullpath in $FOLDER/*.tsv.bz2
# for tbl in yb ybi ybio ybo yi yio yo
for tbl in $TABLES
do
    # echo "Full path: $fullpath";
    # filename=$(basename $fullpath)
    # tsvname="${filename%.bz2}";
    filename="$FOLDER/$tbl.tsv.bz2";
    tsvname="${filename%.bz2}";
    echo $tsvname

    # -- Unzip
    echo "Unzipping to $tsvname ..."
    bzcat $filename > $tsvname

    # tsvpath="$FOLDER/$tsvname"

    # -- Import to database
    tablename="${MODE}_$tbl";
    echo "Importing $tsvname to SQL table $tablename";

    # -- Take the first line of the tsv and convert tabs to commas so we can map tsv fields -> mysql columns
    fields=`head -1 $tsvname | tr '\t' ','`
    echo $fields;
    mysql -uroot $DATAVIVA2_DB_NAME -e "LOAD DATA LOCAL INFILE '$tsvname' INTO TABLE $tablename FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' IGNORE 1 LINES ($fields);";

    # -- Clean up tmp file
    rm $tsvname;
    echo "Completed import to $tablename";
done




{'fraction_non_alphanumeric': 0.13663603675589292, 'fraction_numerical': 0.009188973232121454, 'mean_word_length': 2.8701700154559506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3616442', 'n_tokens_mistral': 940, 'n_tokens_neox': 890, 'n_words': 296}