Using CC How can I sort a specific column from a CSV file A

Using C/C++ :

How can I sort a specific column from a CSV file. Assuming that CSV file has large data set (~9000) on each column.I want to read from one specific column (5th Column) and sort (Bubble or insertion sort) them in descending order. And time it (find the running time of the program). Then, Create a program that will, in turn, run multiple processes “concurrently” using “fork( )” and “exec( )”. Do the sort, again, in parallel for 2 concurrent processes, then 4, and 10 processes. Now time this sort again.

How will you pass data (parts of the array) to each process (IPC)? (Files, pipes, shared memory, message queues?)

Solution

#include <stdio.h>

#include <stdlib.h>

import csv

import itertoolsfrom itertools import groupby as gb

reader = csv.DictReader(open(\'Full_List.csv\', \'r\'))

groups = gb(reader, lambda d: d[\'red label\'])

result = [max(g, key=lambda d: d[\'red label\'])

for k, g in groups]

writer = csv.DictWriter(open(\'output.csv\', \'w\'), reader.fieldnames)

writer.writeheader()

writer.writerows(result)

import pandas as pd

df = pd.read_csv(\'Full_List.csv\')

df = df.sort(\'red label\')

df.to_csv(\'Full_List_sorted.csv\', index=False)

import csv

reader = csv.DictReader(open(\'Full_List.csv\', \'r\'))

result = sorted(reader, key=lambda d: float(d[\'red label\']))

writer = csv.DictWriter(open(\'output.csv\', \'w\'), reader.fieldnames)

writer.writeheader() writer.writerows(result)

reader = cvs.DictReader(ifile)

print \'Try the float version\' sortedlist = sorted(reader, key = lambda d:

float(d[options.statistic]),

reverse=options.high)

except ValueError:

print \'Need to use the text version\' ifile.seek(0) ifile.next() sortedlist = sorted(reader, key=lambda d:

d[options.statistic], reverse=options.high)

.close()

ofile = open(options.fileout, \'wb\')

writer = csv.DictWriter(ofile, fieldnames=outfields, extrasactions=\'ignore\', restval = \'\')

writer.writerow(dict((fn, fn) for fn in outfields))

writer.writerows(sortedlist)

ofile.close()

Using C/C++ : How can I sort a specific column from a CSV file. Assuming that CSV file has large data set (~9000) on each column.I want to read from one specifi
Using C/C++ : How can I sort a specific column from a CSV file. Assuming that CSV file has large data set (~9000) on each column.I want to read from one specifi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site