I have a csv file with Name Mobile Email headers. I want to generate a tuple which has input as a name,email or mobile and output as the corresponding row number. (input,output) tuple.
How to create a tuple <input,output> where input is text in the column and output as row number?
135 Views Asked by NSH At
2
There are 2 best solutions below
0
Adam Smith
On
Is this what you mean by tuples?
import csv
with open('file.csv', 'r', newline='') as f:
reader = csv.DictReader(f)
for tup in enumerate(reader):
print(tup)
Output:
(0, OrderedDict([('name', 'abc'), ('email', '[email protected]'), ('phone', '12345678')]))
(1, OrderedDict([('name', 'lmn'), ('email', '[email protected]'), ('phone', '23456789')]))
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in EXCEL
- Power Query / M Code, extract a list of tables into one main table, some column headers same but some different and in different order (and in row 2)
- Is there a way to validate the cell format (from excel) to fetch the symbol from it (in Java)?
- Excel - Visual Basic, macro with autofill "1"
- Getting Run-time error '13': Type Mismatch using .Find
- Getting website metadata (Excel VBA/Python)
- Excel Code Editor doesn't work (blank window)
- How to find out how many of each 2, 3 and 4 required to fit in 100 using excel?
- How would I apply a rather complex summation formula like this in Excel?
- Removing a Button from Customized Excel Ribbon
- Excel - Update Item Description Based on Accessories Ordered with It
- select duplicates from data based on another column
- How to use VBA to bold just some text
- VBA Code to filter and get values from csv to excel worksheet
- Look up max alpha numeric value
- Azure Batch for Excel VBA
Related Questions in TUPLES
- How can py tuple implicit cast to int?
- How to do a Tuple extension in current Swift? It seems to be available experimentally
- cannot reshape array of size 4 into shape (4,4) in DataFrame where clause
- Nextflow filter entire tuple based on one value
- Using a list of tuple and a relative item of a Tuple as an argument of a method
- How do i swap my keys and values without it reading letter for letter?
- == and Equals for Tuple<object>
- Pygame - Collision of 3 graphics: AttributeError: 'tuple' object has no attribute 'collidepoint'
- Appending tuples returned by for loop
- making a std::tuple from the result of a pack
- Is there a way in c# to deconstruct a tuple and pass the values in one line?
- How to compare two tuple list, return the highest value and the variable name from which the highest value is found?
- Why is the tuple index out of range in the generation of timeseries with tigramite library?
- DMS conversion method not accepting input without seconds component
- Longitude sign incorrect in GeoCoordinates output
Related Questions in RBM
- Is it possible to pass continuous data as input to an RBM model for unsupervised anomaly detection?
- How to evaluate a deep belief network of a stack of BernoulliRBM's performance?
- "RuntimeError: self must be a matrix"
- Generating data from restricted Boltzmann machine
- Loss not decreasing at RBM loss training
- Can I use Restricted Boltzmann Machine for multiple regression output
- How to calculate accuracy in my dataset using Restricted Boltzman Machine (RBM) in R?
- How do I calculate RBM accuracy for larger dataset other than MNIST and what is the simple coding in R Studio?
- Gibbs sampling using sklearn package
- How to create a tuple <input,output> where input is text in the column and output as row number?
- How to get scores from BernoulliRBM
- How to make reccomendations for a specific user by using sklearn BernoulliRBM
- Implementation of Sparse autoencoder by tensorflow
- IndentationError: unindent does not match any outer indentation level with python
- RBM code. AttributeError: 'str' object has no attribute 'shape'. When I try input dataset from excel
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Refer to this docs
You can use this CSV module to do the functionality.
For writing in the file you can use .writerow() function
x,y,zare variables