Apologies in advance if the question is poorly written. This is my second post ever onto the site and I'm a novice programmer. To start, here's what I'm aiming to do:
Step 0: Turn CSV File into record array
Step 1: Split record array into two sub-arrays
Step 2: Shuffle sub-arrays
Step 3: Split two sub-arrays into four smaller sub-arrays
Step 4: Shuffle each sub-array
Step 5: Mix and match values between sub-arrays
Step 6: Append sub-arrays to one of two record arrays and then combine record arrays into single CSV file
The first few steps have been fairly simple.
Step 0:
import numpy as np
import random
from matplotlib.mlab import csv2rec
from matplotlib.mlab import rec2csv
# Get recarray from CSV file
ev = csv2rec('stimuli_1.csv',delimiter = ';')
ev.resize(60) #for even splits
# Create lists to append data to
audio_files = np.recarray([],dtype = ev.dtype)
audio_files_1 = np.recarray([],dtype = ev.dtype)
audio_files_2 = np.recarray([],dtype = ev.dtype)
Step 1:
# Split recarray into two sub-arrays
split_1 = np.split(ev,2)
Steps 2, 3, 4, & 5:
# Shuffle sub-arrays, split again, and then shuffle again
for a in split_1:
#Set count for mix-and-matching
count = 0
#Shuffle
np.random.shuffle(a)
#Split
split_2 = np.split(a,2)
for b in split_2:
count = count+1
#Shuffle
np.random.shuffle(b)
if count == 1:
audio_files_1 = np.append(audio_files_1,b)
elif count == 2:
audio_files_2 = np.append(audio_files_2,b)
Step 6:
audio_files = np.append(audio_files,audio_files_1)
audio_files = np.append(audio_files,audio_files_2)
rec2csv(audio_files,'audio_files.csv')
My problem arises here. The CSV files that are produced are fine, except they have a few very weird values. For example, the first value in the 'audio' field looks like this:
\xb8\xce\xe1H\xeb\x7f\x00\x00\xd0\x12\x81
What causes this? Does it have to do with how I'm appending the arrays to each other?