Question

Using C# or Python, write a code that reads a Microsoft Excel CSV file named "LabAssignment"...

Using C# or Python, write a code that reads a Microsoft Excel CSV file named "LabAssignment" then outputs all the collected and formated data as another Microsoft Excel CSV file named "labOutput"

The CSV file contains 25 colums as well close to 200 rows of data.

Write a code in C# or Python so that:

It removes all unwanted columns along with its data...the columns that should be kept have the following header: "User" "Location" "Feature" "HoursUsed"

Remove all files with the "User" Billy

it outputs the data in the following order by column header:

"User" "Location" "Feature" "HoursUsed"

for "HoursUsed" make sure all the hours are added up

for "Location" remove "HOST:"

output new data into microsoft excel CSV file titles "labOutput"

EXAMPLE

CSV file contains:

"Location" "Feature" "User" "NumUser" "HoursUsed" (and 20 more column headers...)

HOST: USA test Bob 1 0.5

HOST::USA test Billy 1 1

HOST: USA test Bob 1 1

HOST: USA test2 Bob 1 2.5

HOST: USA test2 Jill 1 1

Output:

"User" "Location" "Feature" "HoursUsed"

Bob USA test 1.5

Bob USA test2 2.5

Jill USA test2 1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please give the thumbs up, if it is helpful for you!!. Let me know if you have any doubts.

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 28 07:53:46 2017

@author:
"""

import pandas as pd

df=pd.read_csv('LabAssignment.csv')

new_df = df[['User','Location', 'Feature', 'HoursUsed']].copy()

df1= new_df[df["User"] != 'Billy']

#print(df1)

df2=df1.groupby(['User','Location','Feature']).sum().reset_index()

df2['Location'] = df2['Location'].str.replace('HOST: ',' ')

#print()
#print(df2)

df2.to_csv('labOutput.csv', sep=',', encoding='utf-8',index=False)

Output:

IPython console CConsole 1/A In [19]: runfile(E:/projects/work/HomeworkLib/python/csv operations/csv.py,wdir-E:/projects/work/ c

PC csv. ру LabAssignment.c labOutput.csv labOutput.csv - Excel HOME INSERT PAGE LAYOUT FORMULAS DATA REVIEW VIEW DEVELOPER Lo

Add a comment
Know the answer?
Add Answer to:
Using C# or Python, write a code that reads a Microsoft Excel CSV file named "LabAssignment"...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python help asap! Please give an example of code that reads a csv file then uses...

    Python help asap! Please give an example of code that reads a csv file then uses list comprehension to remove all rows that have empty values.

  • Write a class named SatData that reads a JSON file containing data on 2010 SAT results...

    Write a class named SatData that reads a JSON file containing data on 2010 SAT results for New York City and writes the data to a text file in CSV (comma-separated values) format. It just needs to read a local JSON file - it doesn't need to access the internet. Specifically, your class should have an init method that reads the file, and it should have a method named save_as_csv that takes as a parameter a list of DBNs (district...

  • PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text...

    PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text where each line in the file represents one record of information, and each piece of info in the record is separated by a single comma. Luckily the values won't ever contain commas themselves for this project. But they might start or end with non visible characters (e.g. space, tab). Thus, you must remove the leading and trailing spaces when you store the data in...

  • c++ by microsoft visual studio i wanna the answer for header file , cpp file ,...

    c++ by microsoft visual studio i wanna the answer for header file , cpp file , main file. 1). The function remove of the class arrayListType removes only the first occurrence of an element. Add the function removeAll to the class arrayListType that would remove all occurrences of a given element. Also, write the definition of the function removeAll and a program to test this function. 2)Add the function min to the class arrayListType to return the smallest element of...

  • Please write comments with the program. Python programming!! Part III - write student data In this...

    Please write comments with the program. Python programming!! Part III - write student data In this part the program should create a .csv file and fill it with generated student information. The program should: Ask the user for a name for the .csv file (use your own name for the exercise) Create the .csv file with columns named - ID, first-name, GPA Based on the information received in part I, generate and fill students information in the CSV file Tell...

  • Write an open_file() and a function that reads a csv data file and returns a dictionary...

    Write an open_file() and a function that reads a csv data file and returns a dictionary Microsoft Word - project09_final_RJE.docx 1/17 This project focuses on analyzing a publicly available dataset containing information about the spread of nCoV. Since this is an active situation, this dataset is constantly being updated with the latest figures. However, for our purposes, we will use a static version of the dataset provided to you with this project (ncov.csv). This static version was lasted updated on...

  • Write a PYTHON program that reads a file (prompt user for the input file name) containing...

    Write a PYTHON program that reads a file (prompt user for the input file name) containing two columns of floating-point numbers (Use split). Print the average of each column. Use the following data forthe input file: 1   0.5 2   0.5 3   0.5 4   0.5 The output should be:    The averages are 2.50 and 0.5. a)   Your code with comments b)   A screenshot of the execution Version 3.7.2

  • Question about spark with python. I have a dataset named example.csv, here is data in CSV...

    Question about spark with python. I have a dataset named example.csv, here is data in CSV file below: [0] name [1] name of fruits [2] number of fruits 1. use Pyspark code to plot the number of each fruit. sort the result based on the number of fruits the x-axis is the name of fruits, the y-axis is num of total fruits the output should be apple 10 banana 5 orange 3 mango 2 2. use Pyspark code to plot...

  • Need help with code in C# Create an application that reads a file named Accounts.txt. Your application should load the file and display back the results. The application should allow the user to enter...

    Need help with code in C# Create an application that reads a file named Accounts.txt. Your application should load the file and display back the results. The application should allow the user to enter additional entries and save them back to the same file. The CSV file should contain the following fields: AccountName, InvoiceDate, DueDate, AmountDue If the CSV file contains invalid data you want to inform the user which row contained bad data. Below is an example of what...

  • Write a python program: using class named Example. it will accept a name, the content of...

    Write a python program: using class named Example. it will accept a name, the content of the file. we will use few functions to return the name of the file, owner, set date (time it was created the file), we can also add a line and delete a line from the file. another function that returns all the data in the file. and one that deletes any previous and sets any new data user enters. we can do like Test="a","this...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT