赞
踩
最近想虚拟一些数据,看下有没有自动生成的工具。百度看了下,大概有这么几种方法
1.excel内置公式函数处理
2.使用使用VBA宏生成随机
3.下载方方格子,emm工具是个好工具,蛮多功能的,每月8块
4.Java函数实现
以下是使用java语言实现的随机数据,供数据分析测试用,有需要的自取。
- /**
- * @Author wang
- * @Date 2024/3/23 11:59
- * @PackageName:PACKAGE_NAME
- * @ClassName: RandomUserInfoGenerator
- * @Description: TODO
- * @Version 1.0
- */
- import java.util.Random;
- import java.time.LocalDate;
- import java.time.format.DateTimeFormatter;
-
- public class RandomUserInfoGenerator {
- private static final String[] surnames = {"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨"};
- private static final String[] firstNames = {"伟", "婷", "强", "秀", "刚", "霞", "亮", "丽", "勇", "芳", "明", "娜", "良", "燕", "华", "红"};
- private static final String[] specialCharacters = {"!", "@", "#", "$", "%", "&"};
-
- public static String generateRandomChineseName() {
- Random random = new Random();
- String surname = surnames[random.nextInt(surnames.length)];
- String firstName = firstNames[random.nextInt(firstNames.length)];
- String secondName = firstNames[random.nextInt(firstNames.length)];
- return surname + firstName + secondName;
- }
-
- public static String generateRandomPassword() {
- Random random = new Random();
- StringBuilder password = new StringBuilder();
- for (int i = 0; i < 8; i++) {
- char randomChar = (char) (random.nextInt(26) + 'a');
- password.append(randomChar);
- }
- password.append(specialCharacters[random.nextInt(specialCharacters.length)]);
- return password.toString();
- }
-
- public static String generateRandomRegistrationDate() {
- Random random = new Random();
- LocalDate startDate = LocalDate.of(2024, 1, 1);
- int daysToAdd = random.nextInt(81); // 2024-03-23 - 2024-01-01 = 81 days
- LocalDate registrationDate = startDate.plusDays(daysToAdd);
- return registrationDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
- }
-
- public static void main(String[] args) {
- for (int i = 0; i < 1000; i++) {
- String randomName = generateRandomChineseName();
- String randomPassword = generateRandomPassword();
- String randomRegistrationDate = generateRandomRegistrationDate();
- System.out.println("随机生成的中文姓名:" + randomName + ",随机密码:" + randomPassword + ",注册时间:" + randomRegistrationDate);
- }
- }
- }
- import java.util.Random;
- import java.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
-
- public class RandomUserInfoGenerator {
- private static final String[] surnames = {"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨"};
- private static final String[] firstNames = {"伟", "婷", "强", "秀", "刚", "霞", "亮", "丽", "勇", "芳", "明", "娜", "良", "燕", "华", "红"};
- private static final String[] specialCharacters = {"!", "@", "#", "$", "%", "&"};
-
- public static String generateRandomChineseName() {
- Random random = new Random();
- String surname = surnames[random.nextInt(surnames.length)];
- String firstName = firstNames[random.nextInt(firstNames.length)];
- String secondName = firstNames[random.nextInt(firstNames.length)];
- return surname + firstName + secondName;
- }
-
- public static String generateRandomPassword() {
- Random random = new Random();
- StringBuilder password = new StringBuilder();
- for (int i = 0; i < 8; i++) {
- char randomChar = (char) (random.nextInt(26) + 'a');
- password.append(randomChar);
- }
- password.append(specialCharacters[random.nextInt(specialCharacters.length)]);
- return password.toString();
- }
-
- public static String generateRandomRegistrationDate() {
- Random random = new Random();
- LocalDateTime startDate = LocalDateTime.of(2024, 1, 1, 0, 0, 0);
- int minutesToAdd = random.nextInt(111841); // 2024-03-23 23:59:00 - 2024-01-01 00:00:00 = 111841 minutes
- LocalDateTime registrationDateTime = startDate.plusMinutes(minutesToAdd);
- return registrationDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
- }
-
- public static void main(String[] args) {
- for (int i = 0; i < 1000; i++) {
- String randomName = generateRandomChineseName();
- String randomPassword = generateRandomPassword();
- String randomRegistrationDate = generateRandomRegistrationDate();
- System.out.println("随机生成的中文姓名:" + randomName + ",随机密码:" + randomPassword + ",注册时间:" + randomRegistrationDate);
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。