Last active
November 16, 2017 15:00
-
-
Save KamuelaFranco/554e48fc3bce9733138e9f3a722e8a96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import csv | |
import random | |
import sys | |
try: | |
csv_filename = sys.argv[1] | |
except IndexError: | |
print('USAGE: python shuffler <filename>') | |
sys.exit(0) | |
csv_list = [] | |
try: | |
csv_reader = csv.reader(open(csv_filename), delimiter=',') | |
except FileNotFoundError: | |
print('File not found') | |
sys.exit(0) | |
for row in csv_reader: | |
csv_list.extend(row) | |
shuffled_list = random.sample(csv_list, len(csv_list)) | |
str_shuffled_list = '' | |
for item in shuffled_list[:30]: | |
str_shuffled_list += ' {}'.format(item) | |
print(str_shuffled_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment