[Tutor] Tutor Digest, Vol 132, Issue 57

Rishi Ganesh V rishiglorious at gmail.com
Fri Feb 27 13:21:29 CET 2015


how to pass the argument in the command line
i have the input file as csv and output file as txt
both input file and output file i am passing the value to an argument

like
inputfile=sys.argv[1] , output file=sys.argv[2]

convert(inputfile,outputfile)


how to pass the value in argument

On Fri, Feb 27, 2015 at 4:30 PM, <tutor-request at python.org> wrote:

>  [image: Boxbe] <https://www.boxbe.com/overview> This message is eligible
> for Automatic Cleanup! (tutor-request at python.org) Add cleanup rule
> <https://www.boxbe.com/popup?url=https%3A%2F%2Fwww.boxbe.com%2Fcleanup%3Ftoken%3DSsvtCVRkSHyy2ZOz%252BKAD0kZT6ycCZZheON%252Bq6mOmcXydLmTk%252BpDuKzgMM64Vcz6NRClN2E6kXxuIWs3nMDzy0SfYh0gAqhA%252Bhgrj57WnHuIuP1N1AYJGr%252Fm8sqNL7XNsLsrkdC%252BPQusCtgmOPqlf9Q%253D%253D%26key%3Dern%252BAFx0dKIEaMdbdH29X8RHL%252BlM4fGaLKtde%252BH6UDo%253D&tc_serial=20566764364&tc_rand=1876920614&utm_source=stf&utm_medium=email&utm_campaign=ANNO_CLEANUP_ADD&utm_content=001>
> | More info
> <http://blog.boxbe.com/general/boxbe-automatic-cleanup?tc_serial=20566764364&tc_rand=1876920614&utm_source=stf&utm_medium=email&utm_campaign=ANNO_CLEANUP_ADD&utm_content=001>
>
> Send Tutor mailing list submissions to
>         tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>         tutor-request at python.org
>
> You can reach the person managing the list at
>         tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>    1. Re: Gaussian process regression (Steven D'Aprano)
>    2. Help with python in MAC OS 10.6 (Barbara Heliodora G. Rodrigues)
>    3. Remove a blank row of a Table (shouqiang1989 at sina.com)
>    4. Re: Help with python in MAC OS 10.6 (Alan Gauld)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 27 Feb 2015 12:57:00 +1100
> From: Steven D'Aprano <steve at pearwood.info>
> To: tutor at python.org
> Subject: Re: [Tutor] Gaussian process regression
> Message-ID: <20150227015659.GY7655 at ando.pearwood.info>
> Content-Type: text/plain; charset=us-ascii
>
> On Fri, Feb 27, 2015 at 03:04:25AM +0900, Huijae wrote:
>
> > Hi, I am trying to use Gaussian process regression for Near Infrared
> > spectra. I have reference data(spectra), concentrations of reference
> > data and sample data, and I am trying to predict concentrations of
> > sample data. Here is my code. from sklearn.gaussian_process import
> > GaussianProcess gp = GaussianProcess() gp.fit(reference,
> > concentration) concentration_pred = gp.predict(sample) The results
> > always gave me the same concentration even though I used different
> > sample data. When I used some parts of reference data as sample data,
> > it predicted concentration well. But whenever I use different data
> > than reference data, it always gave me the same concentration. Can I
> > get some help with this problem? What am I doing wrong? I would
> > appreciate any help. Thanks, Jay
>
> Your mail program has mangled your code and mixed up the layout. I
> suggest turning off all formatting, "Rich Text" or HTML mail, since that
> usually destroys the layout of code.
>
> I'm going to try to guess your code's layout:
>
> from sklearn.gaussian_process import GaussianProcess
> gp = GaussianProcess()
> gp.fit(reference, concentration)
> concentration_pred = gp.predict(sample)
>
>
> This is not enough for us to give any meaningful advice. What is
> "sklearn"? What are "reference", "concentration", "sample"? We'd need
> to see actual data, and know what GaussianProcess does, to help.
>
>
> > The results always gave me the same concentration
> > even though I used different sample data.
>
> *Exactly* the same? To 17 decimal places? Or just close to the same?
>
> Perhaps the different samples give the same result because they are
> samples from the same population.
>
>
> > When I used some parts of
> > reference data as sample data, it predicted concentration well. But
> > whenever I use different data than reference data, it always gave me
> > the same concentration.
>
> You may need to ask people who know more about GaussianProcess and how
> it works.
>
>
>
> --
> Steve
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 27 Feb 2015 02:16:56 +0000 (UTC)
> From: "Barbara Heliodora G. Rodrigues" <barbara_hgr at yahoo.com.br>
> To: "tutor at python.org" <tutor at python.org>
> Subject: [Tutor] Help with python in MAC OS 10.6
> Message-ID:
>         <199673520.1431247.1425003416015.JavaMail.yahoo at mail.yahoo.com>
> Content-Type: text/plain; charset=UTF-8
>
> Dear tutor,
> I'd like to ask for help with an issue I have with python. My MAC is with
> OS 10-6.8, darwin kernel, 64 bits. For some reason I updated macports and
> it automatically updated python to 2.7 with a 32 bits library, and it is
> giving me lots of trouble. I can't install any new software that uses
> python, and recently I tried to use some plot (matplotlib) routines that
> were working fine before, simply didn't work, the window with the plot
> didn't open.Is there a way to force macports to install a 64bits version of
> python?I downloaded and installed the 3.4 and 3.1 myself, but still the
> computer only sees the version macports installed.Thank you!Regards,
> B?rbara
>
> ------------------------------
>
> Message: 3
> Date: Fri, 27 Feb 2015 11:19:51 +0800
> From: <shouqiang1989 at sina.com>
> To: "tutor" <tutor at python.org>
> Subject: [Tutor] Remove a blank row of a Table
> Message-ID: <20150227031951.0B004C34F22 at webmail.sinamail.sina.com.cn>
> Content-Type: text/plain;       charset=GBK
>
> Hello, everybody,      I came accross a question a few days
> ago. I wrote a Python script to copy something to a table in a word
> file. For some reaons, there are some blank rows. And I want to remove
> the blank rows. I tried many ways, but all didn't work. Below is the
> code. The code in blue is to remove the  blank row.
>
>
> import codecs
> import os
> import textwrap
> import win32com,string,shutil
> from win32com.client import Dispatch,constants
> def ReportPackage(reportName, reportApi, package=None):
>     desfile='C:\\Daten\\TestCASE5\\Model_hill.doc'
>     w = win32com.client.Dispatch('Word.Application')
>     w.Visible = 1
>     os.path.join(reportApi.GetReportDir(), reportName)
>     fd = w.Documents.Open(desfile)              #open the model file
> info = reportApi.GetInfo()
>     if package is None:
>         package = reportApi.GetMainPackage()
>         result = info.GetResult()
>         execTime = info.GetExecutionTime()
>         pkgName =package.GetName()
>     else:
>         result = package.GetResult()
>         execTime = package.GetTime()
>     i=1
>     s=0
>     f=0
>     e=0
>
>     form = fd.Tables[6]
>     form.Rows.Add()
>
>
>     form.Rows.Last.Cells[2].Range.InsertAfter("%(pkgName)s"  % {'pkgName':
> pkgName})
>     form.Rows.Last.Cells[3].Range.InsertAfter("%(executionTime)s"
> %{'executionTime': execTime})
>
>     form.Rows.Add()
>
>     lines = form.Rows.Last()
>     lines.Cells[0].Range.InsertAfter("Num")
>     lines.Cells[1].Range.InsertAfter("Time")
>     lines.Cells[2].Range.InsertAfter("Comment")
>     lines.Cells[3].Range.InsertAfter("Result")
>
>     testCase =
> package.GetTestCase(excludeSubPackages=reportApi.IsSet("hideSubPackages",
> "True"))
>
>     for reportItem in testCase.IterTestSteps():
>         try:
>
>
>              if reportItem.PResult == "NONE" : #constants.RESULT_NONE:
>                  strResult = ''
>              else :
>                  strResult = reportItem.PResult
>
>
>              lNam = textwrap.wrap(reportItem.PName)
>              maxLines = len(lNam)
>
>
>              fd.Tables[6].Rows.Add()
>
>              if strResult == 'SUCCESS':
>
>  fd.Tables[6].Rows.Last.Cells[3].Shading.BackgroundPatternColorIndex=4
>                  s=s+1
>              elif strResult == 'FAILED':
>
>  fd.Tables[6].Rows.Last.Cells[3].Shading.BackgroundPatternColor=250
>                  f=f+1
>              elif strResult == 'ERROR' :
>
>  fd.Tables[6].Rows.Last.Cells[3].Shading.BackgroundPatternColor=180
>                  e=e+1
>
>
>              if strResult == 'SUCCESS' or strResult == 'FAILED' or
> strResult == 'ERROR' :
>
>  fd.Tables[6].Rows.Last.Cells[3].Range.InsertAfter(strResult)
>                  fd.Tables[6].Rows.Last.Cells[2].Range.InsertAfter(lNam[0])
>                  fd.Tables[6].Rows.Last.Cells[1].Range.InsertAfter(("%.3f"
> % reportItem.PTimestamp))
>                  fd.Tables[6].Rows.Last.Cells[0].Range.InsertAfter(i)
>                  i=i+1
>              else :
>                  pass
>
>
>              for idx in xrange (1,maxLines) :
>                  if fd.Tables[6].Rows[idx].Cells[1] == None :
>                      fd.Tables[6].Rows[idx].Remove()
>                  else :
>                      pass
>         except :
>             break
>
>     s=str(s)
>     f=str(f)
>     e=str(e)
>     fd.Tables[6].Rows.Add()
>     fd.Tables[6].Rows.Last.Cells[2].Range.InsertAfter("s="+s+' ')
>     fd.Tables[6].Rows.Last.Cells[2].Range.InsertAfter("f="+f+' ')
>     fd.Tables[6].Rows.Last.Cells[2].Range.InsertAfter("e="+e+' ')
>     #insert the results in table 7
>
>
>
>     fd.Save.im_self
>     fd.Close()
>
>
>
>
> def _ReportProjectElement():
>     return()
>
>
>
> def ReportProject():
>     return()
>
>
> Thanks in advance.
>
>
>
> --------------------------------
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
> ------------------------------
>
> Message: 4
> Date: Fri, 27 Feb 2015 09:45:52 +0000
> From: Alan Gauld <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Help with python in MAC OS 10.6
> Message-ID: <mcpecf$ven$1 at ger.gmane.org>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> On 27/02/15 02:16, Barbara Heliodora G. Rodrigues wrote:
> > Dear tutor,
> > I'd like to ask for help with an issue I have with python. My MAC is
> with OS 10-6.8,
>
> I'm not a MacOs expert but I know MacOS uses Python in some of its tools
> so do not mess with the standard version, you might break something.
>
> > I can't install any new software that uses python,
>
> What the OS uses as Python should not necessarily impact what you use as
> Python. Usually its just a case of changing a link or creating an alias
> or environment variable.
>
> At the worst case you can edit the shebang line of your scripts.
>
> > I tried to use some plot (matplotlib) routines that were working fine
> before,
>
> How are you running these scripts? Do you just double click an icon or
> do you use a commandline? If the latter what do you type?
> If the former somebody with a modern Mac will need to advise.
>
> > Is there a way to force macports to install a 64bits version of python?
>
> Probably, but I don't know macports.
>
> > I downloaded and installed the 3.4 and 3.1 myself, but still the
>  > computer only sees the version macports installed.
>
> Have you tried calling python3 instead of just python?
> That should find your Python 3.X version.
>
>
> HTH
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> https://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------
>
> End of Tutor Digest, Vol 132, Issue 57
> **************************************
>
>


More information about the Tutor mailing list