Creating a file name is essential for scraping. Is the file name most often date + serial number? In many cases, date + time is fine, but If the number is small, the date + serial number is the most popular, so I made a note of how to create the file name.
Premise Windows Python3.7 The following is when creating a CSV file name with date + serial number If you format datetime.date.today () with strftime, it can be treated as a character string. You can add the desired string to the end.
python
import datetime
hizuke = datetime.date.today()
hizuke = hizuke.strftime('%Y-%m-%d')
file1 = hizuke+"-1.csv" #2020-08-11-1.csv * Today's date
file2 = hizuke+"-2.csv" #2020-08-11-2.csv
Click here for detailed date format https://docs.python.org/ja/3.6/library/datetime.html#strftime-strptime-behavior
vba
Dim strFileNm As String
strFileNm = Format(Now(), "yyyy-mm-dd") & "-1.csv" '2020-08-11-1.csv * Today's date
Click here for detailed date format https://docs.microsoft.com/ja-jp/dotnet/api/microsoft.visualbasic.strings.format?view=netcore-3.1
In the case of vba, the date formatting is the same as the one used in Excel, so it is familiar.
Recommended Posts