Как прочитать CSV-файл с электронными письмами и паролями и сохранить результаты в словаре?

#include <sstream>
#include <vector>
#include <algorithm>
#include <iterator>

const char *input = ",,29870,1,abc,2,1,1,1,0";
int main()
{
    std::stringstream ss(input);
    std::vector<int> output;
    int i;
    while ( !ss.eof() )
    {
       int c =  ss.peek() ;
       if ( c < '0' || c > '9' )
       {
          ss.ignore(1);
          continue;
        }

       if (ss >> i)
       {
          output.push_back(i);
        }

    }

    std::copy(output.begin(), output.end(), std::ostream_iterator<int> (std::cout, " ") );
    return 0;
}
-1
задан martineau 18 January 2019 в 14:15
поделиться

2 ответа

Попробуйте это:

credentials = {}

with open('email_list_test.csv', 'r') as f:

    reader = csv.DictReader(f, delimiter=';') # replace the delimiter character with the one you're using.

    for row in reader:
        credentials.update(row)
0
ответ дан Raydel Miranda 18 January 2019 в 14:15
поделиться

Легко попробуйте это:

my_dict = {}

with open('email_list_test.csv', 'r') as f:
    reader = csv.DictReader(f)
    for row in reader:
        my_dict[row['Email']] = row['Password']
print(my_dict )
0
ответ дан Phillip 18 January 2019 в 14:15
поделиться
Другие вопросы по тегам:

Похожие вопросы: