Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to do in Python
#1
Using Python version 2.7.12 on Linux Mint 18.2. Will be upgrading os next week.
My background is that of various forms of basic and some perl. I have researched
and am unable to figureout how do the following in python.
Can someone help please.
Thanks in advance
oldcity

$datafile = "expenses18";
expenses18 file
041118,1,11.11,1
042618,2,22.22.2
perl code

      open(FILE, '<', $datafile) or die("Could not open* file! datafile\n");
       @lines = <FILE>;
      close(FILE);

   foreach (@lines) {
   ($pdate,$catg,$amt,$howp) = (split(/,/));
# $mm pulled from $pdate
   col1[$mm] = $pdate ;
   col2[$mm] = $catg ;
   col3]$mm] = $amt ;
   col4[$mm] = $howp ;

python code

expenses18 file
041118,1,11.11,1
042618,2,22.22.2

with open('expenses18', 'r') as file:
lines = file.readlines:

## from here on I'm stuck
Reply


Messages In This Thread
How to do in Python - by oldcity - Apr-26-2018, 03:20 PM
RE: How to do in Python - by nilamo - Apr-26-2018, 03:45 PM
RE: How to do in Python - by oldcity - Apr-27-2018, 03:07 PM
RE: How to do in Python - by nilamo - Apr-27-2018, 03:22 PM
RE: How to do in Python - by oldcity - May-24-2018, 03:53 PM
RE: How to do in Python - by snippsat - May-24-2018, 06:22 PM
RE: How to do in Python - by nilamo - May-24-2018, 06:39 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020