Programming

53K

Solutions

41K

Contributors

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

Share tech news, updates, or what's on your mind.

Sign up to Post

I do not know much about programming.

What is the best way to write the contents of an array to a text file, with a space between each item in the text file ?

using PERL.
0
Ensure you’re charging the right price for your IT
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

I know very little about programming.

Could you please help me with code that will read 5 lines of a file, and compare the contents of these five lines to the sixth line, entering the values which match and those that dont match into separate arrays ?

so, eg, reading lines 1-5, compare all values with those in line 6, then reading lines 2-6 and comparing all values with those in line 7, and so on..... each time entering the values that match and those that do not into two separate arrays.

thankyou
0
Hey i need to print a sudoku for school but i am having a hard time doing so.

So i made a load function which prints a pre loaded sudoku like this:

['7,9,0,0,0,0,3,0,1',
 '0,0,0,0,0,6,9,0,0',
 '8,0,0,0,3,0,0,7,6',
 '0,0,0,0,0,5,0,0,2',
 '0,0,5,4,1,8,7,0,0',
 '4,0,0,7,0,0,0,0,0',
 '6,1,0,0,9,0,0,0,8',
 '0,0,2,3,0,0,0,0,0',
 '0,0,9,0,0,0,0,5,4']

For the new function i need to make the function show, which makes the sudoku look like this:

>>> from solver import load, show
>>> show(load("easy/puzzle1.sudoku"))
7 9 _   _ _ _   3 _ 1
_ _ _   _ _ 6   9 _ _
8 _ _   _ 3 _   _ 7 6

_ _ _   _ _ 5   _ _ 2
_ _ 5   4 1 8   7 _ _
4 _ _   7 _ _   _ _ _

6 1 _   _ 9 _   _ _ 8
_ _ 2   3 _ _   _ _ _
_ _ 9   _ _ _   _ 5 4

This is the code for the load function:

def load(filename):
    with open(filename) as sudoku_original:
        sudoku_original = sudoku_original.readlines()
        
        sudoku_original = [line.rstrip('\n') for line in sudoku_original]
        
        sudoku = []
        for line in sudoku_original:
            sudoku.append(line)        
        return sudoku

Open in new window


And this is the format of the show function:
def show(sudoku):
    # TODO
    pass

Open in new window

0
Hey i have a assignment where i have to find a heatwave out of a csv. We can call something a heat wave f there is a period of at least 5 days where the temprature is 25 degrees or more and if in this period there are 3 days with a tempature of 30 degrees or more.
I need to print the first year where a heatwave occured.  Example output: 2019
These are the first lines of the csv:


STAID,SOUID,DATE,TX,Q_TX
162,100522,19010101,-31,0
162,100522,19010102,-13,0
162,100522,19010103,-5,0
162,100522,19010104,-10,0
162,100522,19010105,-18,0
162,100522,19010106,-78,0

DATE is the date in the format year month day
Q is the temprature we are looking for times ten. ( so the temprature is Q/10)


I wrote some code but with this code i cant look if the period has 3 three days with 30 degrees or more. This is the code.

import csv

with open("climate.csv", "r" ) as csvFile:
    reader = csv.DictReader(csvFile)
    heat_wave = []
    heat_date = []
    heat_counter = 0 
    for row in reader:
        row_value = int(row['TX']) / 10
        if row_value < 25 and heat_counter > 5:
            heat_wave.append()
            heat_date.append()
        if row_value > 24:
            heat_counter += 1
        else:
            heat_counter = 0
            
        

Open in new window


Can anyone help me with this?
0
Hee i have this csv which takes dates as 20150731 (meaning 31 july 2015).
I want to print these numbers as 7 aug 1990 so the first three letters of the month.
Does anyone know how to do this?
This is my code so far:

import csv

with open("climate.csv", "r" ) as csvFile:
    reader = csv.DictReader(csvFile)
    max_temp = 0
    min_temp = 0
    for row in reader:
        row_value = int(row['TX'])
        if row_value > max_temp:
            max_temp = row_value
            max_date = int(row['DATE'])
        if row_value < min_temp:
            min_temp = row_value
            min_date = int(row['DATE'])
    

Open in new window


And these are the first lines of the csv:

STAID,SOUID,DATE,TX,Q_TX
162,100522,19010101,-31,0
162,100522,19010102,-13,0
162,100522,19010103,-5,0
162,100522,19010104,-10,0
0
I want to get the maximum of a csv but i get the following error:

keyerror: 'TX'
 
This is my code:
import csv


with open("climate.data", "r" ) as csvFile:
    reader = csv.DictReader(csvFile)
    max_temp = 0
    min_temp = 0
    for row in reader:
        row_value = int(row["TX"])
        if row_value > max_temp:
            max_temp = row_value
        if row_value < min_temp:
            min_temp = row_value
    
    print (min_temp)
            
        

Open in new window


And these are the first lines of the csv:

STAID,SOUID,DATE,TX,Q_TX
162,100522,19010101,-31,0
162,100522,19010102,-13,0
162,100522,19010103,-5,0

Does anyone have a fix for me?
0
I wanna know the longest freezing period from a csv.

The format of the csv is this:

01-06 STAID: Station identifier
08-13 SOUID: Source identifier
15-22 DATE : Date YYYYMMDD
24-28 TX   : Maximum temperature in 0.1 &#176;C
30-34 Q_TX : quality code for TX (0='valid'; 1='suspect'; 9='missing')

STAID,SOUID,DATE,TX,Q_TX
162,100522,19010101,-31,0
162,100522,19010102,-13,0
162,100522,19010103,-5,0
162,100522,19010104,-10,0
162,100522,19010105,-18,0
162,100522,19010106,-78,0

Does anyone know a way to find the longest freezing period and print it in the format:

The longest freezingperiod was 12 days and ended on 29 jun 1999. (example)

Any help would be very much appreciated :)
0
This version of the expression extracts the email address from a string of characters contained within cell E2 and replaces those characters with the result.

I also need versions of the expression that will extract the first name and one to extract the last name.

The email address can possibly be defined as any string of characters that are separated by an @ symbol with no spaces and surrounded entirely by either a (parenthesis) or <chevrons>.

This should work in a google sheet such as this one here https://docs.google.com/spreadsheets/d/1rQ5QC6Ipr5kkBDuNnIMY05Z09Q4q7lqZ52vd0bfCvtY/edit#gid=1895941459

=Regexextract(E2,"[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,4}")

Open in new window

0
I would like to get the minimum and maximum from a csv using python. Does anyone know how to do this.

The csv is made like this:

01-06 STAID: Station identifier
08-13 SOUID: Source identifier
15-22 DATE : Date YYYYMMDD
24-28 TX   : Maximum temperature in 0.1 &#176;C
30-34 Q_TX : quality code for TX (0='valid'; 1='suspect'; 9='missing')

 STAID,    SOUID,    DATE,   TX, Q_TX
   162,100522,19010101,  -31,    0

I want the output to be like this:

The max temp was 34.5 degrees on 13 may 1967
So the 05 in the csv must become the first three letters of the month like may.
If anyone could help me with this i would appreciate it alot :)

My code so far:

import csv
from itertools import islice


with open("climate.data", "r") as dataFile, open("climate.csv", "w") as csvFile:
    climate = csv.reader(dataFile)
    for row in islice(climate, 20, None):        
        print(row)
        
    

Open in new window

0
I am trying to find a way to add sequential bates stamping on a Xerox Atalink C8045 multi function device.

I already understand how to use the bates stamp feature when copying a document and clicking on the Annotations feature and from there click on bates stamp.  

The problem with this is the numbering always starts with 1.  The requirement is for the machine to remember the last number used. The real end goal is to be able to add a unique number to every page printed at the bottom of the page.  I know the machine keeps track of how many copies are printed so this data is stored somewhere and that data would be a good option to print on every page. Either there is a way to do this already in place that I am not finding or there is a way to do this through programming.  Either option will work as long as the end result is to have a unique number printed on every page.
0
Microsoft Azure 2017
LVL 13
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

In Access VBA if the following code changes column names all over the database, what code would change table names? Thanks

Public Function ChangeColumnName()
Dim qdf As QueryDef
Dim strSQL As String
For Each qdf In CurrentDb.QueryDefs
strSQL = vbNullString
strSQL = qdf.SQL
strSQL = Replace(strSQL, "YOUR_OLD_COLUMN_NAME", "YOUR_NEW_COLUMN_NAME") 'e.g strSQL = Replace(strSQL, "Col1", "Col1_1")
qdf.SQL = strSQL
qdf.Close

Next
End Function

Open in new window

0
I have over 60 stores that use cash registers for sales.  I have a method of collecting every transaction from a cash register by capturing the cash registers electronic journal through the serial port.  The data is all text based, but very unstructured.  (I am including a sample file of this data capture to this post.)

The question I have is this:  IF you were tasked with storing, then retrieving and analyzing these data; what type of database storage system would you use?  And why that one?  

I am waffling on whether to use a SQL or NoSQL solution.

Thank you,
Jeff

Here is a sample of the raw data capture.  (Note: about half of the way down there is something called a "Z report"; which is run when a cash register is closed out.  That zero's out all of the balances and totals during that period of time it was operating.)

DATE  10/09/2019 WED  TIME 02:17
                               
2X             @ 4.29          
Purses/Backpack T1         $8.58
Childrens Clothing T1      $1.99
TAX1                       $0.63
TOTAL                     $11.20
CASH                      $12.00
CHANGE                     $0.80
CLERK 1        No.000072   00000
                               
                               
                               
                               
                               
                               
                               
DATE  10/09/2019 WED  TIME 02:18
                               
5X   …
0
I want to show the 5 most used words in the set listpositives. Can anyone help me with this?

Example output: amazing 20.


def positive_word(tweets, positives):

    #prints the top 5 most used positive words

    listpositives= []
    wordfreq= []

    for i in range(len(tweets)):
        for j in range(len(tweets[i])):
            if tweets[i][j] in positives:
                listpositives.append(tweets[i][j])

Open in new window

0
Hi. In my Access form shown in the image below the following event is not firing when I select a different record using the left side selection column with arrows.
The event does however fire if I click to the right in the record. Why would this be?
Private Sub Form_SelectionChange()

     frmMainScreenState.lblSelectedPK.Caption = Me.FirearmPK
     
End Sub

1
0
Hi

In Access I have a for with a sub for in it as shown below. I am using the following code to get a field value but for some reason
it doesn't always work but rather shows the value for the previous record clicked on. Why would this occur?
 
Private Sub Command21_Click()

        Dim FPK as integer
        FPK =  frmFireArmsListState.Form.FirearmPK

End Sub

1
0
Is "odeskwork" a freelancing website completely separate from "upwork"?  

Can USA freelancers join odeskwork site?
0
Hello experts,

The following procedure allows me to remove extra blank lines.

^!Space::
  ; clipboard:="" ; Joe commented out - not needed because Ctrl+c replaces Clipboard
  ;~ Send, ^a ; Luis commented out because he prefers to select the block
  Send, ^c
  ClipWait,1 ; Joe added - good practice to do a ClipWait after Ctrl+c
  If (ErrorLevel=1)
  {
    MsgBox,4144,Error,No text appeared on clipboard after waiting for one second
    Return
  }
  Clipboard:=RegExReplace(Clipboard,"\R\R\K\R+") ; replace two or more consecutive blank lines with a single blank line
  sleep 100
  ; Joe: see if last two chars are CR and/or LF
  LastChar:=SubStr(Clipboard,0,1)
  If ((LastChar="`r") or (LastChar="`n"))
    StringTrimRight,Clipboard,Clipboard,1
  If ((LastChar="`r") or (LastChar="`n"))
    StringTrimRight,Clipboard,Clipboard,1
  
  Send, ^v
  Return

Open in new window


I noticed that removal is not performed when blank lines starts with a space.

Example of block text:

text


 
text with extra blank lines above.

Could you please help me to adjust the AutoHotkey to be able to remove extra blank lines even if they start with a space?

Thank you for your help.
0
Hello,

I am trying to send a click to close document recovery pane button in excel .
The objective is to close the process through reading the image however for the moment I want to understand why click is not applied. I attached a video.
Could you please advice me on how the click should be performed?
I don’t know how to make the click work.


Thank you for your help.


:*:drx::
If (winactive("ahk_exe excel.exe"))
{
  
  WinMaximize
  Sleep, 200
  Click, left,235,1120,4
  Return
}
else
  MsgBox,4112,Fatal Error, Program not supported
Return

Open in new window



Thank you for your help.
20191003_175954-testing-document-reco.7z
0
Hello experts,

I was wondering if there is a way to mute and unmute sound through AutoHotkey.

Thank you for your help.

mute-unmute_20191003_113435.png
0
Rowby Goren Makes an Impact on Screen and Online
LVL 13
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

The Title of the Customer is Located in the CustomerFname Column.  Separate the title into its own column and also retrieve CustomerFname, CustomerLname, City, State and LoanDate of Loans that are more than 1 yr old. how can I separate one column into 2

 TABLE dbo.Loan

INSERT INTO [dbo].[Loan]
           ([CustomerFname]
           ,[CustomerLname]
           ,[PropertyAddress]
           ,[City]
           ,[State]
           ,[BankruptcyAttorneyName]
               ,[UPB]
               ,[LoanDate])
0
Hello,
First at all sorry for my bad English.
I would like to create a kind of lock with no internet connexion and a RTC inside.
The lock will open with a code 8 chars long. The chars can be from 0 to 9 and from A to D. (I use a 16 key keypad)
The main idea is to have a code generator that encrypt with this 14 chars (0-9 and A-D) a code that says to the lock : you will have to open from this date until this date. And because i want the code to work only with the serial of one lock the code have to be compatible only with the lock I create the code for.

So to resume :
I have a lock with a 16 keys that are 0-9 and A-D the last two are R for reset and V like run :)
The lock have a serial number could be 000 to 999
When I create the code the code have to contain on max 8 chars : the start date, end date and the serial of the lock.

I've tried some ideas like work with a base 14 or something like. Use a kind of offset from the a defined date that is the same on the lock and the generator and then use the difference from this date to create the start date. Use the serial of the lock to do a CRC so when the lock check the code if the CRC is not ok then it won't open.

Well as you see I'm getting lost so if you have a simple idea please help

Thanks a lot
0
Hello experts,

I set up the following AutoHotkey script on the basis of the following question:
https://www.experts-exchange.com/questions/29157425/Autohotkey-Open-edit-file-based-on-file-extension.html
+^F1::
FormatTime, CurrentDateTimeFileSelected,, yyyyMMdd_HHmmss
FileSelected:=GetSelectedFile()
SplitPath,FileSelected,FileNameSelected,FileDirectory,FileExtension
NewFileName:= SubStr(FileNameSelected,1, -5) . "_" . CurrentDateTimeFileSelected . "." . FileExtension 
;~ FileCopy, %FileSelected%, 
NewFile:=FileDirectory . "\" . NewFileName
Msgbox %NewFile%
FileCopy, %FileSelected%, %NewFile%

GetSelectedFile(hwnd="") {
; this function by sinkfaze: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=77#p395
 WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
 WinGetClass class, ahk_id %hwnd%
 if (process = "explorer.exe")
 if (class ~= "Progman|WorkerW") {
 ControlGet, files, List, Selected Col1, SysListView321, ahk_class %class%
 Loop, Parse, files, `n, `r
 ToReturn .= A_Desktop "\" A_LoopField "`n"
 }
 else if (class ~= "(Cabinet|Explore)WClass") {
 for window in ComObjCreate("Shell.Application").Windows
 if (window.hwnd==hwnd)
 sel := window.Document.SelectedItems
 for item in sel
 ToReturn .= item.path "`n"
 }
 return Trim(ToReturn,"`n")
}
Return

Open in new window


Prior to adding to my AutoHotkey file I have some questions:
1-I used the GetSelectedFile function in another AutoHotkey script declare in my AutoHotkey file. What is the best practice:
Have just a single function for the various AutoHotkey scripts that use it and place the function at the end of the file? Or declare the function every time when an AutoHotkey script use it? I supposed the first option is the best but I would like to have a confirmation.
2-Could you please confirm the structure of the AutoHotkey and if you have additional advice or another best way to copy and rename file please let me know. For example where should I add an error level condition?

I attached a video to illustrate that it works here in an OS 10.
Thank you for your help.
copy-rename-file_20190928_234539.7z
0
Hello experts,

The following script allows me to send style code based on a selection:


!^c:: ;code
Send, ^x
Send, Sleep, 50 ClipWait,1 If (ErrorLevel=1) { MsgBox,4144,Error, No text appearing after one second Return } Send, ^v Sleep, 50 Send, {End} Sleep, 50 Send, Return


Instead of selecting and go to initial position I thought that the best is to simplify it as following through using directly by the clipboard:


!^c:: ;code
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
Clipboard:="" . ClipboardVar . ""
Sleep, 50
MsgBox,4160,Success,Your clipboard has been properly copied.
Return


Prior to adding to my AutoHotKey file could you please let me know your advice on the script structure and if I can go ahead by adding this on my AutoHotKey file.

Thank you very much for your help.
0
Hello experts,
I set up the following AutoHotkey to hide and show windows by class.
I took as a reference the AutoHotkey reported at https://www.experts-exchange.com/questions/29159194/AutoHotkey-WinHide.html#a42949009
:?*:hhx::
HideClass:="Chrome_WidgetWin_1" ; title must contain this - case insensitive
WinGet,AllWindows,List ; get list of all windows that exist
NumWin:=AllWindows ; number of all windows
NumHidden:=0 ; number of windows hidden
Loop,%NumWin% ; loop through all windows
{
  Handle:=AllWindows%A_Index% ; get the handle of each window
  WinGetClass,Class,ahk_id %Handle% ; get the class of each window
  If (InStr(Class,HideClass)) ; "contains" match and case insensitive
  {
    WinHide, ahk_class %Class% ; hide the window if it matches
    NumHidden:=NumHidden+1 ; increment number of windows hidden
  }
}
MsgBox,4160,Number Hidden: %NumHidden%,Done hiding windows that contain this in the Class:`n`n%HideClass%
Return

:?*:ssx::
DetectHiddenWindows,On ; so that WinGet finds the hidden windows
ShowClass:="Chrome_WidgetWin_1" ; Class must contain this - case insensitive
WinGet,AllWindows,List ; get list of all windows that exist
NumWin:=AllWindows ; number of all windows
NumShown:=0 ; number of windows shown
Loop,%NumWin% ; loop through all windows
{
  Handle:=AllWindows%A_Index% ; get the handle of each window
  WinGetClass,Class,ahk_id %Handle% ; get the class 

Open in new window

0
hi am geting the following error

11 Sep 2019

18:37 All files are up-to-date



18:37 Error running 'All in tdm-pet-clinic': No junit.jar
this is my pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>guru.springframework</groupId>
    <artifactId>tdm-pet-clinic</artifactId>
    <version>0.0.5</version>
 
    <modules>
        <module>pet-clinic-data</module>
        <module>pet-clinic-web</module>
    </modules>
 
    <packaging>pom</packaging>
 
    <name>tdm-pet-clinic</name>
    <description>SFG Pet Clinic Project</description>
 
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
 
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <jaxb.version>2.3.0</jaxb.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
    </properties>
 
    <dependencies>
        

Open in new window

0

Programming

53K

Solutions

41K

Contributors

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.