I have an ImportCommand class which reads a file and imports the data from that file to a database. The command itself works fine.
However, I need to run the same command several times with different files.
My .bat file:
#echo off
cd c:\xampp\htdocs\mysite\protected\
yiic import c:\sourcefiles\users_1.csv
yiic import c:\sourcefiles\users_2.csv
yiic import c:\sourcefiles\users_3.csv
The first command runs then the script stops and files users_2.csv and users_3.csv are not processed.
After struggling with this for a while, I found this answer: How to run multiple .BAT files within a .BAT file
So the .bat file should be:
#echo off
cd c:\xampp\htdocs\mysite\protected\`
call yiic import c:\sourcefiles\users_1.csv
call yiic import c:\sourcefiles\users_2.csv
call yiic import c:\sourcefiles\users_3.csv
Use CALL command. Without CALL, control is transferred to other batch and is not returned.
Try this
#echo off
cd c:\xampp\htdocs\mysite\protected\
yiic import c:\sourcefiles\users_1.csv && yiic import c:\sourcefiles\users_2.csv && yiic import c:\sourcefiles\users_3.csv
This will execute the desired command one by one . It only proceeds one operation is successful.
Related
import csv
fails, alert "csv.py" is not accessed
yes, there is no file of that name in my current working directory.
Where can I locate a copy of csv.py to use in my current project.
import urllib.request, urllib.error, urllib.parse #this command works
import obo #this command works because I have obo.py in my directory
import csv # csv is underlines with white dots, csv is not accessed
where do I seek csv.ph?
running windows Visual Studio version 1.73.1
Newbie error. The warning from Visual Studio only meant that I imported a module but didn't use it in the program.
My folder structure is like this
cloud_fn_dir
cf1_dir
main.py
util.py
requirements.txt
test_main_cf1.py
cf2_dir
main.py
requirements.txt
test_main_cf2.py
cf3_dir
main.py
requirements.txt
test_main_cf3.py
I am executing unit tests and generating coverage report using command - pytest -v --cov=main --cov-report=html
If I am executing the command from inside the Cloud function folders i.e. cf1_dir or cf2_dir folders then the pytest command works as expected and executes the unit tests and generates reports inside that folder.
But I wish to execute all the unit tests at once and generate a single report and hence I tried to execute the same command from outermost folder i.e. cloud_fn_dir and encountered Import Error where the test_main_cf3.py file is trying to import Class of cf1_dir main.py file.
Each of the test file is importing it's respective main.py file in it and creates an object and calls the methods to test. So when I execute the pytest command it is making the last test file i.e. test_main_cf3.py to import main of cf1_dir main.py and execute the methods. Pytest is trying to import the first encountered main.py class
How do I resolve this import error ?
I have made a game using pygame and now want to convert the script to an exe file. However, when doing this and starting the exe file I get an error saying "Failed to execute script (main.py)". I have tried everything from youtube videos to reading similar questions on Stack Overflow. But nothing works, I get the same error every time. How can I solve this?
Does it have to do something with my imports?
The import that I use in my script:
pygame
random
winsound
mixer (from pygame)
Avoid all of these problems and use PyInstaller (link to related question):
Download this library with pip by typing in the Command Prompt:
py -m pip install pyinstaller
Then, type cd [path to the file].
Finally, type py -m PyInstaller --onefile [script name].py.
PyInstaller will turn your code into one .exe file, in the folder dist, analyzing the modules you need.
After the installation, you can then delete all the other files, like the folder build for example.
If you need other attached files, like images, put them in the folder where the .exe file has been created.
Anyways, if you type exit() anywhere in your code, PyInstaller will raise an error. Simply import sys and type sys.exit() instead.
I want to batch import multiple *.CSV files to a SQLite3 database using a batch command line.
I have a batch file(loader.bat) which calls loader.sql to import the csv file into test.db (using sqlite3.exe).
sqlite3.exe test.db ".read loader.sql"
loader.sql is a sqlite script that imports data.csv into a table (tb_data)
.import data.csv tb_data
This works for importing a single file (data.csv). I want to import all the *.csv files (eg data123.csv, data456.csv, data789.csv) in a folder into the same table(tb_data).
I am thinking of using a for loop in the batch script to iterate through the files.
for %%a in (*.csv) do (
echo %%a
sqlite3.exe test.db ".read loader.sql"
)
How do I pass the parameters from the batch script to the sqlite script(loader.sql)?
Just combine all your csv files into one first and use your original command to load that:
copy *.csv combined.cv
https://scipher.wordpress.com/2010/05/10/setting-your-pythonpath-environment-variable-linuxunixosx/#comment-219
I did this tutorial to set up my pythonpath variable in my Linux computer,
the odd thing is that I can only import my modules from /home
I did cd /home and vi .bash_profile, did the changes pointing directly to my folder with my modules, such
PATH=$PATH:$HOME/bin:"/share/my_modules"
PYTHONPATH="$PYTHONPATH:/share/my_modules"
export PATH
export PYTHONPATH
and save the file.
from there I can do python and import my modules,
but if I go to any other directory and I try to import my modules, it fail =(.
if I do
import sys
sys.path
my folder /share/my_modules is not there =( but do show in the terminal from /home.
do I need to set up a .bash_profile file in each folder? I am missing something?
thanks guys.
https://help.ubuntu.com/community/EnvironmentVariables
reading this document, explains that are 2 ways to set it up,
one is modifying the /etc/environment file.
or making an sh file under /etc/profile.d/*.sh
and putting the variables like
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0
export PATH=$PATH:$JAVA_HOME/bin
that way every time a terminal is open will run that, export those variables and will work.