<jupyter_start><jupyter_text><jupyter_code>!curl -O https://raw.githubusercontent.com/pcsilcan/aed/master/data/publications.tsv
%%file 1.cpp
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

struct Pub {
    string  title, desc, pubDate;
    int     idPub, idUser, nlikes;

    Pub(string title, string desc, string pubDate,
        int idPub, int idUser, int nlikes)
        : title(title), desc(desc), pubDate(pubDate),
        idPub(idPub), idUser(idUser), nlikes(nlikes) {}
};

bool loadData(string filename, vector<Pub*>& pubs) {
    ifstream file(filename);

    if (!file.is_open()) {
        cerr << "No se pudo abrir el archivo";
        return false;
    }

    bool titles = true;
    string title, desc, pubDate, idPub, idUser, nlikes;    
    while (file >> idPub) {
        file.get();
        file >> idUser; file.get();
        getline(file, title, '\t');
        getline(file, desc, '\t');
        file >> pubDate; file.get();
        file >> nlikes; file.get();

        if (titles) {
            titles = false;
            continue;
        }
        pubs.push_back(new Pub(title, desc, pubDate,
                               stoi(idPub), stoi(idUser), stoi(nlikes)));
    }
    file.close();
    return true;
}

bool savePubs(string filename, vector<Pub*>& pubs) {
    ofstream file(filename);

    if (!file.is_open()) {
        cerr << "No se pudo abrir el archivo";
        return false;
    }
    file << "id\tidU\ttitle\tdesc\tfecpub\tnlike\n";
    for (auto pub : pubs) {
        file << pub->idPub << '\t'
             << pub->idUser << '\t'
             << pub->title << '\t'
             << pub->desc << '\t'
             << pub->pubDate << '\t'
             << pub->nlikes << endl;
    }
    file.close();
    return true;
}

int main() {
    vector<Pub*> pubs;
    loadData("publications.tsv", pubs);

    cout << pubs.size() << endl;

    pubs[0]->nlikes++;
    pubs[0]->nlikes++;

    savePubs("publications.tsv", pubs);
    

    return 0;
}
!g++ -std=c++17 -O2 1.cpp -o p1 && ./p1
!head publications.tsv
%%file 1.py
import random
for i in range(1, 1001):
    for j in range(random.randint(3, 10)):
        print(f'{i}\t{random.randint(1, 1000)}')
!python 1.py > followers.tsv<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1640893470790378, 'fraction_numerical': 0.010738831615120275, 'mean_word_length': 2.3223965763195435, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 31, 'https://': 1, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '638060', 'license': 'CC0-1.0', 'n_tokens_mistral': 851, 'n_tokens_neox': 826, 'n_words': 193, 'path': '20202/aed_20202_141_leyendo_publicaciones.ipynb', 'repo_name': 'pcsilcan/aed', 'size': '2328'}