I currently have a quite big program written in FoxPro (prg file). Now FoxPro is actually really getting outdated, so what I want to ask is the following:
Is it possible to convert all the FoxPro code (.prg file) to Python? Is there a simple trick/code for this? Python has to become my main coding platform, so I don't need to use FoxPro anymore for when I want to adjust some code or something else. Does someone have experience with this?
I hope to hear from you, appreciate your help.
PS: Please note that I am quite new to Python.
There are plenty of people from the FoxPro community who migrated into the Python world certainly, but there are no tools that I know of for converting source code. As with most of these 'can I convert from language x to language y' questions, you would spend more time getting the result into shape than you would just documenting and rewriting.
There are some Python scripts that implement common Visual FoxPro functions in the download section on Leafe.com which might help.
You might want to check out this question.
There is also vfp2py.
Python comes with support for excellent SQLite database built-in with the sqlite3 module. (You are probably aready using sqlite, but you might not even know it.) Storing the data in an sqlite database means you will not have to worry about not being able to access it for the rest of your life.
Related
I am wondering how can I convert Stata code into Python code.
For example, my Stata code looks like
if ("`var1'"=="") {
local l_QS "select distinct CountryName from `l_tableName'"
ODBCLoad, exec("`l_QS'") dsn("`dsn'") clear
}
And I want to convert it to Python code such as
if (f"{var1}"=="") :
l_QS = f"select distinct CountryName from {l_tableName}"
SQL_read(f"{l_QS}", dsn = f"{dsn}")
I am new to coding so I don't know what branch of computer science knowledge or what tools/techniques are relevant. I suppose knowledge about compilers and/or using regular expressions may help so I put those tags on my question. Any high-level pointers are appreciated, and specific code examples would be even better. Thanks in advance.
A very simple workaround would be to use the subprocess module included with python and write a basic command line wrapper to your scripts to use their functionality, then build your code from now on in python.
You could also look into possible API functionality in Stata if you have a whole lot of Stata code and it would take forever to convert it manually to python. This would require you to have access to a server and could be potentially costly, but would be cleaner than the subprocess module and wouldn't require the source code to be contained on your local machine. Also note that it's possible that Stata does not have tools to build an API.
As far as I am aware there are no projects that will directly parse a file from any language and convert it into python. This would be a huge project, although maybe with machine learning or AI it would be possible, though still very difficult. There are libraries for wrapping code in C and C++ (others too I'm sure I just know that these are available), but I can't find anything for Stata.
HI I am new managing excel files, I would like to know if there is any variable in xlutils, xlrd, xlm, etc libraries that give true or false in case Macros are activated or now? Is there any way to know it from metadata before open? Wat is the best approach for know it?
Thanks a lot in advance.
It's technically possible but very unlikely that Excel is calling any Python functions.
A quick Google Search shows lots of people asking if VBA can use Python, and a few theoretical responses, but nothing solid.
What I would do to confirm, is move all the "mystery python scripts" to another folder. If someone complains that things suddenly don't work any more, then move them back.
If a couple months pass and everything's still working properly, it's unlikely that anyone needs them.
Edit:
Figures... as I was writing that answer someone posted a VBA/Python question!
...but out of curiousity, I queried SE Data Explorer:
Questions with tags like %vba% or %excel%: 212,299
Questions with tags like %python% and (%vba% or %excel%): 5,808 (2.7%)
I've done a little basic coding in Java, VBA and C++ before but still a complete newbie, I'm trying to understand what exactly it is that I could do with Python and how it would be useful.
For example, at my appointment-setting job I get customer data in an Excel sheet from my boss, that I'm supposed to put into the CRM system before calling them. It takes me probably at least 5 minutes each time and it's very tedious. Could I automate this process using Python? I've been looking into learning Python recently and thought this might be a good first goal-project in that case, if it's possible and not too difficult to do.
Thanks in advance.
I'm not sure what CRM is, but pulling excel content into your python program is easy. I have used this (https://automatetheboringstuff.com/chapter12/) for processing excel content in the past.
Yes, you can use Python for this. Automate the Boring Stuff with Python is a good resource for getting started. Once you understand how to do this, you need to find out if your CRM has some sort of API or tool that will allow you to post data with your Python code. Chances are good that it does.
Can you guys please tell if building my own birtviewer like reporting tool but using python is a crazy idea. The company I'm working now, we are using birtviewer to generate reports for the clients, but I'm already getting frustrated tweaking the code to suit our client needs and it's written on massive java code which I don't have any experience at all. And they don't want to mavenize birtviewer, so every new releases I have to manually update my local copy and mavenize it. And the fact that it is really owned by a private company worries me about the future of birtviewer. What do you guys think?
Sure. Write it. Make it open source and give us a git repo to have a little look... Honestly if the problem exists solve it.
Is it possible to make python run on your homepage? I know, this is a really stupid question but please don't pick on me for my stupidity :)
If it is possible, how? Do you have to upload/install the executing part of Python to you website using FTP? or...?
Edit: Just found out my provider does not support python and that shell access is completely restricted. Problem solved :)
Everything depends on the hosting provider you use for your homepage -- do they offer Python among their services, and, if so, what version, and how do you write server-side scripts to use it (is it CGI-only, or...?) -- if not, or the version / deployment options disappoint, what do they allow in terms of giving you shell access and running long-time processes?
It's impossible for us to judge any of these aspects, because every single one of them depends on your hosting provider, and absolutely none of them depends on Python itself!-)
Yes, you can. I don't know exactly how but I know it is possible. Mabye look into this website:
https://trinket.io/
This website lets you do this. I sent them a message to see how they do it so I will update this to let you know after they respond.
Python is a scripting language, though it is used gracefully for building back end web applications.